WriteBash - In Linux, to perform the move or rename of a file or directory, we use the mv command. This command performs one of the two features mentioned, depending on usage. In either case, the original filename no longer exists after the operation. mv is used in much the same way as cp command.
Use mv command
To move or rename file or directory “item1” to “item2”.
mv item1 item2
To move one or more items from one directory to another.
mv item... directory
mv command useful options
mv command have many options as the same as cp command:
|-b||make a backup of each existing destination file but does not accept an argument|
|-f||do not prompt before overwriting|
|-i||Before overwriting an existing file, prompt the user for|
confirmation. If this option is not specified, mv will
silently overwrite files.
|-u||When moving files from one directory to another, only|
move files that either don’t exist, or are newer than the
existing corresponding files in the destination
|-v||Display informative messages as the move is|
To display all options of mv command, execute command below:
Some examples of mv command
Read more: Listing the contents of a directory
Rename file1 to file2.
mv file1 file2
Move file1 and file2 to a directory, you can use for directory as the same way.
mv file1 file2 dir/
This command works very similar to the cp command. The use of the this command should be very careful because it can delete the target file or directory during the use of the command.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.