LinuxCommandLibrary

mv

moves and renames files and directories

TLDR

Move file

$ mv [source] [destination]
copy
Rename file
$ mv [oldname.txt] [newname.txt]
copy
Move multiple files to directory
$ mv [file1] [file2] [directory/]
copy
Move with confirmation
$ mv -i [source] [destination]
copy
Force overwrite
$ mv -f [source] [destination]
copy
Verbose output
$ mv -v [source] [destination]
copy
Don't overwrite existing
$ mv -n [source] [destination]
copy

SYNOPSIS

mv [options] source destination

DESCRIPTION

mv moves and renames files and directories. It's a core Unix utility.
The tool relocates files in the filesystem. Also used for renaming within same directory.

PARAMETERS

SOURCE

File or directory to move.
DESTINATION
Target location.
-i
Prompt before overwrite.
-f
Force, no prompts.
-n
No clobber, don't overwrite.
-v
Verbose mode.
--help
Display help information.

CAVEATS

Overwrites by default. Atomic within same filesystem. Different behavior across filesystems.

HISTORY

mv is one of the original Unix commands, present since Version 1 AT&T Unix in 1971.

SEE ALSO

cp(1), rm(1), rename(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard