How to change file extension in Red Hat Enterprise Linux.

Solution Verified - Updated -

Environment

Red Hat Enterprise Linux 4/5/6

Issue

  • What are the steps to change file extensions  in Red Hat Enterprise Linux.
  • Like Windows, I can manually change a file extension by simply right-clicking the file and renaming its extension.

       Is there a similar way in Red Hat?

  • How to change file extenstion in RHEL?

Resolution

There are two ways to change file extensions in RHEL, 1)  Command line  2) Graphical Mode.

Command line:

Open terminal and type following command "#mv filename.oldextension filename.newextension"

For example if you want to change "index.html" to "index.php" you would type the following command.

#mv index.html index.php

Graphical Mode:

Same as Microsoft Windows right click and rename its extension.

Multiple file extension change.

for x in *.html; do mv "$x" "${x%.html}.php"; done

This script will change all files in current directory ending with html extension to

php extension. (*.html to *.php), You can customize it as per your requirment.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments