Sunday, May 20, 2012

How To: Rename a File in Linux on the Command Line

Suppose the spelling of mickey.txt has been mis-spelt as mick.txt , then renaming can be done by the "mv" command. The sample syntax and usage is as given below.

Syntax: mv <old_file_name> <new_file_name>
$ mv mick.txt mickey.txt


The "mv" command is also used to move files from one location to the other.


2 comments:

  1. Hi Abhi,

    so
    Basically there no direct command or rule for renaming a file or folder in linux?
    So the rule is to replace the file with mv commamd with different name at same location will do the work of renaming a file or folder!!

    ReplyDelete
    Replies
    1. Thanks anand for reading my post! As per my knowledge there's no command that does renaming. The closest that comes is the "rename" command whose syntax goes like this - rename . It is used to rename multiple files in one go...
      I will write about this command once I learn more about the perl regular expressions

      Delete