mv (short for move) is a Unix command that moves one or more files or directories from one place to another. The original file is deleted, and the new file may have the same or a different name. If possible (i.e. when the original and new files are on the same file system), mv will rename the file instead. Write permission is required on all directories being modified.
mv myfile mynewfilename renames a file
mv myfile otherfilename renames a file and deletes the existing file "myfile"
mv myfile /myfile moves 'myfile' from the current directory to the root directory
mv myfile dir/myfile moves 'myfile' to 'dir/myfile' relative to the current directory
mv myfile dir same as the previous command (the filename is implied to be the same)
mv myfile dir/myfile2 moves 'myfile' to dir and renames it to 'myfile2'
mv foo bar baz dir moves multiple files to directory dir
mv --help shows a very concise help about the syntax of the command
man mv prints an extensive user manual for 'mv' in the terminal
In all cases, the file or files being moved or renamed can be a directory.
Note that when the command is called with two arguments (as mv name1 name2 or mv name1 /dir/name2), it can have three different effects, depending on whether name2 does not exist, is an existing file, or is an existing directory. If the user intends to refer to an existing directory, /. (or in some Unix versions / is sufficient) may be appended to the name to force the system to check this. To move a file to a new directory, the directory must be created first.