Move Files in a Directory

Move files in a directory easily in Linux via "mv" command.

mv

Definition:

The mv command is one the frequently used commands which is used to move files and directories. We can also use this command to rename files and directories. File names or directory names are given as an argument. If the files given as argument are present in the same directory then you can only rename them, not move them. The source file name would be renamed as destination file name. You can move multiple files/directories simulatenously using mv command.

Syntax:

mv [options] [source] [destination]

Options:

Option Meaning
-i Means intercative. This option is only used to warn the user about overwrite issues
-b Used to make backup copies of files
-v Means verbose. It displays information about each file being processed.
- -help Gives detailed information about mv command
- -version This option is to check the version of the installed program

Example:

  1. Rename a file and keep it in the same directory mv my_file_1 my_file_2

Get hands-on with 1200+ tech skills courses.