A2oz

How Do You Rename a File in Unix?

Published in Unix Commands 1 min read

You can rename a file in Unix using the mv command.

Here's the basic syntax:

mv [original filename] [new filename]

For instance, to rename a file named "document.txt" to "report.txt", you would type:

mv document.txt report.txt

Renaming Files in Different Directories

You can also move and rename a file to a different directory using the mv command.

For example, to move a file named "image.jpg" from the "images" directory to the "documents" directory and rename it to "profile.jpg", you would use the following command:

mv images/image.jpg documents/profile.jpg

Additional Information

  • The mv command can be used to rename multiple files at once.
  • You can use wildcards like * and ? to rename multiple files with similar names.

Related Articles