Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

NAME

mv - move (rename) files

SYNOPSIS

mv [OPTION ...] [-T] SOURCE DESTINATION
mv [OPTION ...] SOURCE ... DIRECTORY

DESCRIPTION

Rename SOURCE to DESTINATION, or move SOURCE(s) to DIRECTORY.

OPTIONS

-i
Prompt before overwriting.

-n
Do not overwrite an existing file.

-T
Treat DESTINATION as a normal file.

-u
Move only when the source file is newer than the destination file, or when the destination file is missing.

EXAMPLES

To rename a file

Code Block
mv foo.sql tariq.sql

To rename a directory

Code Block
mv foo tariq

To move a directory

Code Block
mv /home/tariq/shell /home/tariq/destination

 To overwrite an existing file using mv command:

Code Block
mv /home/tariq/foo.sql /home/tariq/dest/foo.sql

 To prompt before overwriting an existing file using mv command:

Code Block
mv -i /home/tariq/foo.sql /home/tariq/dest/foo.sql

 To move only when the source file is newer than the destination file, use the -u option

Code Block
mv -u /home/tariq/foo.sql /home/tariq/dest/foo.sql

NOTES

      If both -n and -i are specified, -n will take precedence.
If both -n and -u are specified, -n will take precedence.

SEE ALSO

rename