mv: move and rename files

Updated November 2026

mv moves files and directories to another place, or renames them. Unix has no separate rename command for single files: renaming is just moving to a new name.

mv [options] source target mv [options] source ... directory

Common options

OptionMeaning
-iAsk before overwriting
-nNever overwrite
-vShow what is moved
-bKeep a backup of an overwritten file (GNU)
-t dirMove everything into dir (GNU; useful with xargs)

Examples

mv draft.txt final.txt              # rename
mv final.txt ~/Documents/           # move into a directory
mv *.log old-logs/                  # move many files
mv -i new.conf /etc/app/app.conf    # ask before replacing
mv project project-2025             # rename a directory
mv -- -strange-name.txt normal.txt  # a name starting with "-": end options with --

Renaming many files

mv renames one file at a time. For bulk renames, use a loop or the rename tool:

# change the extension of every .jpeg file to .jpg
for f in *.jpeg; do mv -- "$f" "${f%.jpeg}.jpg"; done

# with the Perl rename (Debian/Ubuntu package "rename"); -n shows what would happen
rename -n 's/ /_/g' *        # replace spaces with underscores
rename 's/ /_/g' *

On RHEL and Fedora, the default rename command is a simpler util-linux tool with different syntax: rename .jpeg .jpg *.jpeg.

Things to know