• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

rename Command Examples in Linux

by Deepika

The rename command is a utility in Unix-like operating systems that allows you to rename multiple files at once. It is used to change the names of files and directories, and it provides a powerful and flexible way to manipulate file names.

The rename command can also be used with regular expressions, allowing you to match more complex patterns in file names and perform more sophisticated transformations. This makes it an extremely useful tool for bulk renaming of files, especially in scenarios where you need to rename a large number of files or where the names of the files have a specific pattern.

rename Command Examples

1. Rename files using simple substitutions (substitute ‘foo’ with ‘bar’ wherever found):

# rename foo bar *

2. Dry-run – display which renames would occur without performing them:

# rename -vn foo bar *

3. Do not overwrite existing files:

# rename -o foo bar *

4. Change file extensions:

# rename .ext .bak *.ext

5. Prepend “foo” to all filenames in the current directory:

# rename '' 'foo' *

6. Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits:

# rename foo foo00 foo? && rename foo foo0 foo??

Filed Under: Linux

Some more articles you might also be interested in …

  1. uuidgen: command not found
  2. How to monitor your CPU on debian or ubuntu systems
  3. Changing the IPset rules from IPtables to Firewalld in CentOS/RHEL 7
  4. extundelete Command Examples in Linux
  5. CentOS / RHEL : How to create new LVM based swap partition
  6. pmap Command Examples in Linux
  7. CentOS / RHEL : How to get the date and time of executed command in the history command output
  8. How to Stop/disable Firewalld on CentOS/RHEL 8
  9. lvchange Command Examples in Linux
  10. lvm: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright