In this article, you will learn 5 common uses of ```
mv
command in Linux. The
mv
1. Moving files using mv command
If you need to move file abc.txt for example in another directory, lets say /home/sonik/Desktop/ here is how it's done:
mv abc.txt /home/sonik/Desktop/
2. Take a backup before overwriting
Using the<strong> -```
b
```</strong> option, you can take backup of destination file before overwriting the existing file.
mv -bv *.txt ./home/sonik/Desktop/
3. Renaming files and directories
Renaming files or directories works just as same as moving a file, except you have to be in the same location.
mv file.txt filenew.txt
mv dir dirnew
4. Don't override any existing files
The following command merges one folder to another, but doesn't override any existing files
mv -n dir1/* ./home/dir2
mv -u dir1/* ./home/dir2
5. Move the files from parent directory to one of the child
You can move all the files from parent directory to the child directory with the following command:
cd parent
mv !(child1|child2) child1
We hope you enjoyed this <a href="https://lateweb.info/category/linux/">article</a>. if that is so please rate this page with the stars bellow and subscribe to our <a href="https://www.youtube.com/channel/UCh7Q9uaAt5-Z2lCZXX3OsvQ">YouTube channel</a>.