Rename - what does "s//" vs "y//" mean?

In the first case:

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

you are running a regular expression against filenames and replacing the 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, the range A-Z is changed to the range a-z, making the filenames lower case.

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


From man sed:

s/regexp/replacement/    
       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.

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