Linux and Unix mv command tutorial with examples

“mv” command is used to moves a group of file to a another/different directory.

“mv” command can also use to rename file and directory.

This command does not create a new copy of file , it only rename it.

When we rename it does not consume any additional space on the disk.

Syntax:

Example of mv command in Linux and Unix

Rename File using mv command

Suppose we want to rename a file Mybook01 to MyNotes01 than command is as follows:

Rename Directory using mv command

Suppose we want to rename a directory dir01 to Mydir01 than command is as follows:

Move Number Of Files To a Directory using mv command

Suppose we want to move three files Mybook01 , MyBook02 & MyBook03 into a directory dir01 than command is as follows:

Above command moves three files Mybook01 , MyBook02 & MyBook03 into a directory dir01.

Linux Unix mv -i command

-i, –interactive option is used for interactive mode. It Prompts before override a file

Linux Unix mv -n command

-n , –no-clobber don’t override the file while moving

Linux Unix mv -f command

-f, –force option do not prompt before override

Linux Unix mv -t command

-t , –target-directort=DIRECTORY option moves all to directory

Linux Unix mv -v command

-v –verbose explains what is being done

Read More

Linux and Unix rm command tutorial with examples

Linux and Unix tail command tutorial with examples

Reference

mv(1) – Linux man page