mv renames files or moves them to a different directory. If you specify multiple files, the target (that is, the last path name on the command line) must be a directory. mv moves the files into that directory and gives them names that match the final components of the source path names. When you specify a single source file and the target is not a directory, mv moves the source to the new name, by a simple rename if possible.
If a destination file exists and you do not have write permission for it, mv prompts with the name of the existing file. If you answer y or yes, it deletes the destination and then moves the source.
If the file being moved is a sparse file and the file system to which it is
being moved does not support sparse files, mv warns that
the resulting file will be larger. If the
moves the ACLs associated with the specified file along with the file itself. When used with
-p, permissions are moved as well.
This option is only available on NTFS file systems.
When you use mv to do a simple rename (that is, simply move it on the same device), ACLs are automatically moved with the file and the
-aoption is not required. However, when you use mv to move a file to another device, you must specify the -aoption or the ACLs are not moved with the file. -d
delays moving the specified files until the system is rebooted.
This option relies upon the underlying operating system's capability to perform the action at reboot time.
does not ask if you want to overwrite an existing destination without write permission; it automatically behaves as if you answered yes. If you specify both
-fand -i, mv uses the option that appears last on the command line. -i
always prompts before overwriting an existing file, whether or not the file is read-only. If you specify both
-fand -i, mv uses the option that appears last on the command line. -q
suppresses warning messages. Error messages are still displayed.
moves directory and all its contents (files, subdirectories, files in subdirectories, and so on). For example, mv -r dir1 dir2 moves the entire contents of dir1 to dir2/dir1. mv creates any directories that it needs.
prints file names to standard output as they are being processed.
Possible exit status values are:
Failure due to any of the following:
- — argument had trailing slash (/) but was not a directory
- — file could not be found
- — input file could not be opened for reading
- — output file could not be created or opened for output
- — read error occurred on an input file
- — write error occurred on an output file
- — input and output files were the same file
- — input file could not be unlinked
- — input file could not be renamed
- — fatal error was encountered when using the
-rerrors include the following:
Failure due to any of the following:
- cannot allocate target string
mv has no space to hold the name of the target file. Try to free up some memory to give mv more space.
- filename read only?
You are attempting to move a file, but there is already a file with the target name and the file is read-only. If you really want to write over the existing file, type y and press ENTER. If you do not want to write over the existing file, type n and press ENTER.
- source "name" and target "name" are identical
The source and the target are actually the same file (for example, because of links on UNIX and POSIX-compliant systems). In this case, mv does nothing.
- unreadable directory "name"
mv cannot read the specified directory (for example, because you do not have appropriate permissions).
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 2000. Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012.
MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
MKS Toolkit 9.5 Documentation Build 3.