mv (move) is a Unix command that moves one or more files or directories from one place to another. It is also used to rename a file/folder.
In this article we will discus different examples of mv command.
Move a file or Directory
So, use below command to move your file from one place to another.
mv file-name destination-path
In below example, I have moved a file “abc.txt” to a test folder placed in / path.
mv abc /
you can see example in below image
Move Multiple files
So, if you want to move multiple files into a directory in a single command, issue the following.
mv file-one.txt file-two.txt file-three.txt /test
you can see example in following image
Rename a File or Directory
Let say we have a file called exp.txt and we want to rename it as “demo.txt” then we will use following command
mv exp.txt demo.txt
Now you can see in below image that exp.txt file has been renamed with demo.txt
Now rename a directory test with testnew
mv test testnew
And that is it.