Moving and renaming are performed with the same command,
To move a file, use the
Our last argument should be the target path to that directory.
$ mv file1 file2 file3 dir1/
A good habit to form is to make sure that your target path ends with a / if you are using a directory. Having the / at the end tells the shell that the destination is a directory. Check out how the shell notifies you that the directory does not exist when we accidently commit a typo.
$ mv file1 /home/JohnDoe/diretcry/
mv: rename file1 to /home/JohnDoe/diretcry/: No such file or directory.
If we were to omit the /, the shell would assume that we are trying to move our file to /home/JohnDoe and rename our file to diretcry.
We can use
mv command to move a file to your current directory with a new name (in other words, rename it).
$ mv oldFileName newFileName
mv shares common options with
The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.$ Check price
Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.$ Check price