mv

From Initq

Jump to: navigation, search

Move or rename files or directory.

mv myfile mynewfilename    renames a file
mv myfile otherfilename    renames a file and deletes the existing file "otherfilename"
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. If moving to a new directory, then make sure that the directory exists. There is no flag to create the directory if it does not exist.

Personal tools