MV(1) User Commands MV(1)

mv - move or rename files and directories

mv [-f] [-i] [-b size] file1 [file2 . . . ] target

Mv moves (changes the name of) file1 to target. If target is an existing regular file, its content is overwritten. Its mode and owner are preserved; the mode of the source file is used otherwise. If the mode of target forbids writing (and standard input is terminal for /usr/5bin/mv and /usr/5bin/s42/mv), mv prints the mode (see chmod(2)) and reads the standard input to obtain a line; if the line begins with y, the move takes place; if not, the file is not moved.

If target is a directory, one or more files are copied into the directory with their original file-names.

Mv refuses to move a file onto itself.

The mv command accepts the following options:

Mv will not ask for confirmation even if the modes of the target file do not permit writing. Overrides the -i option in /usr/5bin/posix/mv and /usr/5bin/posix2001/mv.
mv will ask for confirmation before overwriting an existing target. For /usr/5bin/mv and /usr/5bin/s42/mv, this flag will be automatically disabled if standard input is not a terminal. Overrides the -f option in /usr/5bin/posix/mv and /usr/5bin/posix2001/mv.

The following option is an extension:

When a regular file is moved to another file system, its data must be copied. This option overrides the automatically determined i/o buffer size for such copies; size is given in bytes.

cp(1), cat(1), pr(1), unlink(2)

Use either

mv -- -file target

or

mv ./-file target

to move files that begin with a hyphen character.

If source and target lie on different file systems, mv must copy the file and delete the original. In this case any linking relationship with other files is lost, but mv will preserve linkage inside the moved tree. Mv will try to preserve access and modification times, user and group ownerships, and file permission bits. Failing to preserve these modes is not considered an error, only /usr/5bin/posix/mv and /usr/5bin/posix2001/mv will print an error message. Special files such as block and character devices, FIFOs, and symbolic links are recreated in the target hierarchy.

The pathname contained in a symbolic link is not changed when the link is moved. Symbolic links with relative pathnames may thus change or lose their target if moved to a different level in the file hierarchy.

1/24/05 Heirloom Toolchest