Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The man page ( gives two examples:

rename ’s/\.bak$//’ *.bak
rename ’y/A-Z/a-z/’ *

So it's either s or y and then /replaceThis/withThis

What does the leading s and y mean? Are there other options?

share|improve this question
up vote 6 down vote accepted

In the first case:

rename ’s/\.bak$//’ *.bak

you are running a regular expression again filenames and replacing matching part of expressions (.bak at the end of a file name) with the second expression (which is empty).

In the second case:

rename ’y/A-Z/a-z/’ *

you are matching against the regular expression pattern space and transliterating to the target. In other words, 'A-Z' is changed to' a-z', making the filenames lower case.

I suggest you look at the man page for sed for more commands and more details. I'll add that I believe the 's' command is used most often. regex (section 7) and perl documentation may also be of help. In particular, here's a tutorial on perl and regular expressions.

Attempt to match regexp against the pattern space. If success‐ ful, replace that portion matched with replacement. The replacement may contain the special character & to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-expressions in the regexp.

Transliterate the characters in the pattern space which appear in source to the corresponding character in dest.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.