coreutils: mv invocation
1
1 11.4 ‘mv’: Move (rename) files
1 ==============================
1
1 ‘mv’ moves or renames files (or directories). Synopses:
1
1 mv [OPTION]... [-T] SOURCE DEST
1 mv [OPTION]... SOURCE... DIRECTORY
1 mv [OPTION]... -t DIRECTORY SOURCE...
1
1 • If two file names are given, ‘mv’ moves the first file to the
1 second.
1
1 • If the ‘--target-directory’ (‘-t’) option is given, or failing that
1 if the last file is a directory and the ‘--no-target-directory’
1 (‘-T’) option is not given, ‘mv’ moves each SOURCE file to the
1 specified directory, using the SOURCEs’ names.
1
1 ‘mv’ can move any type of file from one file system to another.
1 Prior to version ‘4.0’ of the fileutils, ‘mv’ could move only regular
1 files between file systems. For example, now ‘mv’ can move an entire
1 directory hierarchy including special device files from one partition to
1 another. It first uses some of the same code that’s used by ‘cp -a’ to
1 copy the requested directories and files, then (assuming the copy
1 succeeded) it removes the originals. If the copy fails, then the part
1 that was copied to the destination partition is removed. If you were to
1 copy three directories from one partition to another and the copy of the
1 first directory succeeded, but the second didn’t, the first would be
1 left on the destination partition and the second and third would be left
1 on the original partition.
1
1 ‘mv’ always tries to copy extended attributes (xattr), which may
1 include SELinux context, ACLs or Capabilities. Upon failure all but
1 ‘Operation not supported’ warnings are output.
1
1 If a destination file exists but is normally unwritable, standard
1 input is a terminal, and the ‘-f’ or ‘--force’ option is not given, ‘mv’
1 prompts the user for whether to replace the file. (You might own the
1 file, or have write permission on its directory.) If the response is
1 not affirmative, the file is skipped.
1
1 _Warning_: Avoid specifying a source name with a trailing slash, when
1 it might be a symlink to a directory. Otherwise, ‘mv’ may do something
1 very surprising, since its behavior depends on the underlying rename
1 system call. On a system with a modern Linux-based kernel, it fails
1 with ‘errno=ENOTDIR’. However, on other systems (at least FreeBSD 6.1
1 and Solaris 10) it silently renames not the symlink but rather the
1 directory referenced by the symlink. ⇒Trailing slashes.
1
1 _Note_: ‘mv’ will only replace empty directories in the destination.
1 Conflicting populated directories are skipped with a diagnostic.
1
11 The program accepts the following options. Also see ⇒Common
options.
1
1 ‘-b’
1 ‘--backup[=METHOD]’
1 ⇒Backup options. Make a backup of each file that would
1 otherwise be overwritten or removed.
1
1 ‘-f’
1 ‘--force’
1 Do not prompt the user before removing a destination file. If you
1 specify more than one of the ‘-i’, ‘-f’, ‘-n’ options, only the
1 final one takes effect.
1
1 ‘-i’
1 ‘--interactive’
1 Prompt whether to overwrite each existing destination file,
1 regardless of its permissions. If the response is not affirmative,
1 the file is skipped. If you specify more than one of the ‘-i’,
1 ‘-f’, ‘-n’ options, only the final one takes effect.
1
1 ‘-n’
1 ‘--no-clobber’
1 Do not overwrite an existing file; silently do nothing instead. If
1 you specify more than one of the ‘-i’, ‘-f’, ‘-n’ options, only the
1 final one takes effect. This option is mutually exclusive with
1 ‘-b’ or ‘--backup’ option.
1
1 ‘-u’
1 ‘--update’
1 Do not move a non-directory that has an existing destination with
1 the same or newer modification timestamp. If the move is across
1 file system boundaries, the comparison is to the source timestamp
1 truncated to the resolutions of the destination file system and of
1 the system calls used to update timestamps; this avoids duplicate
1 work if several ‘mv -u’ commands are executed with the same source
1 and destination. This option is ignored if the ‘-n’ or
1 ‘--no-clobber’ option is also specified.
1
1 ‘-v’
1 ‘--verbose’
1 Print the name of each file before moving it.
1
1 ‘--strip-trailing-slashes’
11 Remove any trailing slashes from each SOURCE argument. ⇒
Trailing slashes.
1
1 ‘-S SUFFIX’
1 ‘--suffix=SUFFIX’
11 Append SUFFIX to each backup file made with ‘-b’. ⇒Backup
options.
1
1 ‘-t DIRECTORY’
1 ‘--target-directory=DIRECTORY’
1 Specify the destination DIRECTORY. ⇒Target directory.
1
1 ‘-T’
1 ‘--no-target-directory’
1 Do not treat the last operand specially when it is a directory or a
1 symbolic link to a directory. ⇒Target directory.
1
1 ‘-Z’
1 ‘--context’
1 This option functions similarly to the ‘restorecon’ command, by
1 adjusting the SELinux security context according to the system
1 default type for destination files and each created directory.
1
1 An exit status of zero indicates success, and a nonzero value
1 indicates failure.
1