mv - move files


mv [-fi] source target
mv [-fi] source ... directory


In its first form, the mv(1) utility renames the file named by the source operand to the destination path named by the target operand. This form is assumed when the last operand does not name an already existing directory.

In its second form, mv(1) moves each file named by a source operand to a destination file in the existing directory named by the directory operand. The destination path for each operand is the path name produced by the concatenation of the last operand, a slash, and the final path name component of the named file.

The following options are available:

Do not prompt for confirmation before overwriting the destination path. (Any previous occurences of the -i option is ignored.)
Causes mv(1) to write a prompt to standard error before moving a file that would overwrite an existing file. If the response from the standard input begins with the character "y", the move is attempted. (Any previous occurences of the -f option is ignored.)

If the destination path does not have a mode that permits writing, mv(1) prompts the user for confirmation as specified for the -i option.

As the rename(3) call does not work across file systems, mv(1) uses cp(1) and rm(1) to accomplish the move. The effect is equivalent to:

rm -f destination_path && \
cp -pr source_file destination && \
rm -rf source_file

Specifying more than one -f or -i options is not considered an error. The option which appears last on the command line is the one used.

The mv(1) utility exits 0 on success, and >0 if an error occurs.