mv command in Linux/Unix

Linux mv command.

mv command is used to move files and directories.

mv command syntax

$ mv [options] source dest

mv command options

mv command main options:

option description
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update - move when source is newer than destination
mv -v verbose - print source and destination files
man mv help manual

mv command examples

Move main.c def.h files to /home/usr/rapid/ directory:

$ mv main.c def.h /home/usr/rapid/

 

Move all C files in current directory to subdirectory bak :

$ mv *.c bak

 

Move all files in subdirectory bak to current directory :

$ mv bak/* .

 

Rename file main.c to main.bak:

$ mv main.c main.bak

 

Rename directory bak to bak2:

$ mv bak bak2

 

Update - move when main.c is newer:

$ mv -u main.c bak
$

 

Move main.c and prompt before overwrite bak/main.c:

$ mv -v main.c bak
'bak/main.c' -> 'bak/main.c'
$

 

Linux move files ►

 


See also

Contact Us

LINUX
ABOUT