manpagez: man pages & more
info coreutils
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 mv: Move (rename) files

mv moves or renames files (or directories). Synopses:

 
mv [option]… [-T] source dest
mv [option]… sourcedirectory
mv [option]… -t directory source

mv can move any type of file from one file system to another. Prior to version 4.0 of the fileutils, mv could move only regular files between file systems. For example, now mv can move an entire directory hierarchy including special device files from one partition to another. It first uses some of the same code that's used by cp -a to copy the requested directories and files, then (assuming the copy succeeded) it removes the originals. If the copy fails, then the part that was copied to the destination partition is removed. If you were to copy three directories from one partition to another and the copy of the first directory succeeded, but the second didn't, the first would be left on the destination partition and the second and third would be left on the original partition.

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 is not affirmative, the file is skipped.

Warning: If you try to move a symlink that points to a directory, and you specify the symlink with a trailing slash, then mv doesn't move the symlink but instead moves the directory referenced by the symlink. See section Trailing slashes.

The program accepts the following options. Also see Common options.

-b
--backup[=method]

See section Backup options. Make a backup of each file that would otherwise be overwritten or removed.

-f
--force

Do not prompt the user before removing a destination file.

-i
--interactive

Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response is not affirmative, the file is skipped.

--reply=how

Deprecated: to be removed in 2008.
Specifying ‘--reply=yes’ is equivalent to using ‘--force’. Specify ‘--reply=no’ to make mv act as if ‘no’ were given as a response to every prompt about a destination file. Specify ‘--reply=query’ to make mv prompt the user about each existing destination file. Note that ‘--reply=no’ has an effect only when mv would prompt without ‘-i’ or equivalent, i.e., when a destination file exists and is not writable, standard input is a terminal, and no ‘-f’ (or equivalent) option is specified.

-u
--update

Do not move a non-directory that has an existing destination with the same or newer modification time. If the move is across file system boundaries, the comparison is to the source time stamp truncated to the resolutions of the destination file system and of the system calls used to update time stamps; this avoids duplicate work if several ‘mv -u’ commands are executed with the same source and destination.

-v
--verbose

Print the name of each file before moving it.

--strip-trailing-slashes

Remove any trailing slashes from each source argument. See section Trailing slashes.

-S suffix
--suffix=suffix

Append suffix to each backup file made with ‘-b’. See section Backup options.

-t directory
--target-directory=directory

Specify the destination directory. See section Target directory.

-T
--no-target-directory

Do not treat the last operand specially when it is a directory or a symbolic link to a directory. See section Target directory.

An exit status of zero indicates success, and a nonzero value indicates failure.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2017
Individual documents may contain additional copyright information.