•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

rename a file in linux

Trusted By
25,000+ Customers (Since 2001)
  • Home
  • Client
  • Qa Forum
  • rename a file in linux

Posted By: Jeremy | 1 Replies | Last Reply On: May 23, 2017 06:22:54

how to rename a file in linux? 

Psychz - Raviteja

Votes: 54Posted On: May 23, 2017 06:22:54
 

A file in linux can be renamed by using multiple methods. Here are some of the important methods used to rename a file in linux.

 

The "mv" (move) command

The "mv" command in linux can be used to move as well as rename a file in linux. Suppose you want to rename a file you just have to move the file to the same directory using a different name. Let us demonstrate this with an example.

Imagine you have a file named "file1" in the directory "document". You want to rename this file as "file2". Run the following command in your terminal.

 

mv file1 file2

 

 The syntax of "mv" command is :

mv "old file name" "new file name"

 

 

Some options that can be used with the "mv" command are :

1. Verbose (-v)

 

mv -v "old file name" "new file name"

This is the verbose option that will display what task the command has performed.  

Sample output - 

 

2. Interactive (-i)

 

mv -i "old file name" "new file name"

This option will prompt you before making any changes.

 

The "rename" Command

The "rename" command can be used to rename multiple files. 

Its syntax is given as : 

 

rename 's/old_name/new_name' files
rename -[options] 's/old_name/new_name' files

 

Suppose you want to change all ".jpg" files to ".jpeg" files you simply run the following command.

 

rename 's/jpg/jpeg/' *.jpg

 

These were two basic commands used to rename a file in linux. These commands come with a variety of options. Once you get the basic understanding you can move on to complex options.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Was this reply helpful?

Related topics

  • SSH File Transfer
  • How to find a file using find and locate command on Linux?
  • How to search in Linux?
  • Basic and useful Linux commands
  • Linux Server Backup Solution
  • Linux Find Commands
  • Linux File Permissions Cheat Sheet
  • How to setup a dedicated server for Minecraft
  • How to free up disk space on a cPanel server
  • Top Useful Features Of Linux Mint
  • Scientific Linux and its features
  • What Scientific Linux is and its features
  • Top Myths About Linux Security
  • How to setup a dedicated server for Ark: Survival Evolved
  • How To Remotely Connect To Windows Server?
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2022 Psychz Networks, A Profuse Solutions Inc Company