fortypoundhead.com

MV

Posted On 2007-05-02 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1564


Move or rename files or directories.

SYNTAX
mv [options]... Source Dest

mv [options]... Source... DirectoryIf the last argument names an existing directory, `mv'' moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it renames the first as the second. It is an error if the last argument is not a directory and more than two files are given.

OPTIONS

-b
--backup
Make a backup of each file that would otherwise be overwritten or
removed.

-f
--force
Remove existing destination files and never prompt the user.

-i
--interactive
Prompt whether to overwrite each existing destination file,
regardless of its permissions. If the response does not begin
with `y'' or `Y'', the file is skipped.

-S SUFFIX
--suffix=SUFFIX
Append SUFFIX to each backup file made with `-b''.
The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.

-u
--update
Do not move a nondirectory that has an existing destination with
the same or newer modification time.

-v
--verbose
Print the name of each file before moving it.

-V METHOD
--version-control=METHOD''
Change the type of backups made with `-b''. METHOD can be:

t, numbered make numbered backups
nil, existing numbered if numbered backups exist, simple otherwise
never, simple always make simple backups

--help display help and exit
--version output version information and exit

Examples

Rename the file apple as orange.doc:
mv apple orange.doc

Move orange.doc to the Documents folder:
mv orange.doc ~/Documents/orange.doc

Rename a bunch of file extensions
e.g. change *.txt into *.htm
for f in *.txt; do mv ./"$f" "${f%txt}htm"; done`mv'' can move only regular files across filesystems.

If a destination file exists but is normally unwritable, standard input is a terminal, and the `-f'' or `--force'' option is not given, `mv'' prompts the user for whether to replace the file. (You might own the file, or have write permission on its directory.) If the response does not begin with `y'' or `Y'', the file is skipped.


About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.227.51.103

Before you can post, you need to prove you are human. If you log in, this test goes away.




Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers