GNU mv Cheatsheet
#
mv
is a command used to move or rename files and directories on GNU systems.
Basic Usage
#
Command/Option | Example | Description |
---|
mv source dest | mv file1.txt file2.txt | Rename file1.txt to file2.txt |
mv source dest/ | mv file.txt /path/to/dir/ | Move file.txt to /path/to/dir/ |
mv source1 source2 dest/ | mv file1.txt file2.txt /path/to/dir/ | Move file1.txt and file2.txt to /path/to/dir/ |
Options
#
Command/Option | Example | Description |
---|
-i | mv -i file.txt /path/to/dir/ | Prompt before overwriting files |
-f | mv -f file.txt /path/to/dir/ | Force move by overwriting files without prompt |
-u | mv -u file.txt /path/to/dir/ | Move only when the source file is newer than the destination file |
-v | mv -v file.txt /path/to/dir/ | Verbose mode, show the move operation |
Examples
#
Command/Option | Example | Description |
---|
mv -i | mv -i oldname.txt newname.txt | Prompt if newname.txt exists |
mv -f | mv -f file.txt /path/to/dir/ | Forcefully move file.txt to /path/to/dir/ |
mv -u | mv -u file.txt /path/to/dir/ | Move file.txt only if it is newer |
This cheatsheet covers essential mv
commands and options for GNU systems.