mv - Move files

Synopsis

mv [-f | -i] source_file target_file

mv [-f | -i] source_file ... target_dir

Description

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

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

It is an error for either the source_file operand or the destination path to specify a directory except when both are directories.

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

Options

-f
Do not prompt for confirmation before overwriting the destination path. The -i option is ignored if the -f option is specified.
-i
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 first character for the YES response in the current locale, the move is attempted.

Exit Status

Related information

Examples
  1. Move the file "perl5" into the directory "/usr/bin" and prompt the user to overwrite if the file exists.
    mv -i perl5 /usr/bin