2.4.18. mv#

mv moves or renames files and directories.

2.4.18.1. Common mv usage#

  • Both moving and renaming are performed with mv.

  • Follows the same notation as cp

  • Does not require the option, -r !!

mv [source] [destination]
  • [source] can be a file, folder, /path/to/file, or /path/to/folder

  • [destination] can be /path/to/file, or /path/to/folder with NewFileName or NewFolderName

2.4.18.1.1. Move/Rename Files and Folders#

  • Moving a file is straightforward; you can even rename it at the destination

# Move file.txt to the folder, destination, in /path/to, and rename it to newname.txt
mv file.txt /path/to/destination/newname.txt
  • Same for folders

mv directory path/to/destination/newname

mv is similar to cp, but it deletes the source. mv is also useful for renaming files!

mv source.txt new.txt