Javatpoint Logo
Javatpoint Logo

Linux rename Regular Expressions

The rename command is mostly used to search a string and replace it with another string

Syntax:

Example:

Linux Rename Regular Expression1

Look at the above snapshot, all the 'text' are converted into 'txt'.

You can also replace a string with the following syntax.

Syntax:

Example:

Linux Rename Regular Expression2

Look at the above snapshot, all '.txt' are converted into '.TXT'.

In above two examples the strings used were present only at the end of the file name. But this example is different.

Example:

Linux Rename Regular Expression3

Look at the above snapshot, only the first occurence of sarched string is replaced.


A Global Replacement

In the above example only first 'txt' was replaced in 'atxt.txt'. To replace both the 'txt' we can use a global replacement 'g'.

Syntax:

Example:

Linux Rename Regular Expression4

Look at the above snapshot, both the 'txt' are replaced with 'TXT'.


Case Insensitive Replacement

In case insensitive replacement, a string can be replaced with a case insensitive string.

Syntax:

Example:

Linux Rename Regular Expression5

Look at the above snapshot, all '.text' are replaced with '.txt'.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA