The mv command

move (rename) files 9 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-i, --interactive
prompt before overwrite
-n, --no-clobber
do not overwrite an existing file
-v, --verbose
explain what is being done

Examples

mv oldname.txt newname.txt
mv file.txt documents/
mv file.txt documents/newname.txt

Move and rename at once

mv file1.txt file2.txt documents/
mv olddir/ newdir/
mv -i file.txt dest/

Ask before overwriting

mv -v file.txt dest/

Verbose output

mv -n file.txt dest/

Never overwrite existing files

mkdir -p jpg && mv "$f" jpg/

Quotes keep "holiday photo.jpg" one name

Lessons that use mv

Related commands