MV COMMAND

 HomeCodeLinux  mv command 

mv command in Linux/Unix

Linux mv command.

mv command is used to move files and directories.

mv command syntax

$ mv [optionssource dest

mv command options

mv command main options:

optiondescription
mv -fforce move by overwriting destination file without prompt
mv -iinteractive prompt before overwrite
mv -uupdate - move when source is newer than destination
mv -vverbose - print source and destination files
man mvhelp 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'
$

 

Previous Post Next Post