mv: Move (rename) files
mv moves or renames files (or directories). Synopses:
mv [option]… [-T] source dest mv [option]… source… directory mv [option]… -t directory source…
mvmoves the first file to the second.
mvmoves each source file to the specified directory, using the sources’ names.
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
mv always tries to copy extended attributes (xattr), which may
include SELinux context, ACLs or Capabilities.
Upon failure all but ‘Operation not supported’ warnings are output.
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: Avoid specifying a source name with a trailing slash,
when it might be a symlink to a directory.
mv may do something very surprising, since
its behavior depends on the underlying rename system call.
On a system with a modern Linux-based kernel, it fails with
However, on other systems (at least FreeBSD 6.1 and Solaris 10) it silently
renames not the symlink but rather the directory referenced by the symlink.
See Trailing slashes.
mv will only replace empty directories in the
destination. Conflicting populated directories are skipped with a diagnostic.
The program accepts the following options. Also see Common options.
See Backup options. Make a backup of each file that would otherwise be overwritten or removed.
Do not prompt the user before removing a destination file. If you specify more than one of the -i, -f, -n options, only the final one takes effect.
Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response is not affirmative, the file is skipped. If you specify more than one of the -i, -f, -n options, only the final one takes effect.
Do not overwrite an existing file. If you specify more than one of the -i, -f, -n options, only the final one takes effect. This option is mutually exclusive with -b or --backup option.
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.
Print the name of each file before moving it.
Remove any trailing slashes from each source argument. See Trailing slashes.
Append suffix to each backup file made with -b. See Backup options.
Specify the destination directory. See Target directory.
Do not treat the last operand specially when it is a directory or a symbolic link to a directory. See Target directory.
This option functions similarly to the
by adjusting the SELinux security context according
to the system default type for destination files and each created directory.
An exit status of zero indicates success, and a nonzero value indicates failure.