Showing posts with label mv. Show all posts
Showing posts with label mv. Show all posts

Saturday, December 28, 2013

How to rename a file in Linux

0 comments

How to rename a file in Linux

"mv" command renames the file, It needs only the source of old file and the location will be in with a new name, or with the same name.

It is obvious from the command "mv" that moves files, however It renames them too as well.

An example to demonstrate renaming a file in the same path :

mv {old-file-name} {new-file-name}
mv file myfile

In fact, It moved the file in the same location and gave it a new name.

Note : You can do the same example, but changing the name is necessary or you will get an error.

This example moved a file from a path to another without changing Its name

mv {old-path/file-name} {new-path/file-name}
mv ~/Myfile ~/Desktop/Myfile 

This example changes the name and the path as well :

mv {old-path/file-name} {new-path/new-file-name}
mv ~/Myfile ~/Desktop/Mynewfile


Note : The same can be done with folders.

     
Read more...