Bash Move Files
mv relocates files and directories, and because there's no separate rename command in bash, mv is also how you rename things.
Moving a File to a New Location
mv takes a source and a destination, just like cp, but instead of duplicating the source it relocates it — the file exists only at the new path afterward, with nothing left behind at the old one.
Move a file into a folder
$ mv invoice.pdf archive/
$ ls archive
invoice.pdf
$ ls
archiveRenaming with mv
Bash has no dedicated rename command for simple cases. Instead, you 'move' a file to a new name in the same directory, which mv treats identically to moving it elsewhere — only the destination path is different.
Rename a file
$ mv draft.txt final-report.txt
$ ls
final-report.txtMoving Multiple Files and Directories
List several source files before a final destination directory to move them all in one command. mv also works on directories directly with no special flag required, since moving never needs to walk into a tree and copy bytes — it just changes the path.
Move several files at once
$ mv chart.png table.png notes.txt reports/
$ ls reports
chart.png notes.txt table.png- mv old.txt new.txt — rename a file
- mv file.txt folder/ — move a file into a directory
- mv folder1/ folder2/ — rename a directory, or move it if folder2 already exists
- mv -i src dest — ask before overwriting an existing destination
- mv -n src dest — never overwrite an existing destination