How to rename a file in Linux

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.

http://linuxxcommand.blogspot.com/2013/12/how-to-rename-file-in-linux.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s