Today's Perl Advent Calendar entry talks about the Perl rename command1. This is an awesome command, originally written by Larry Wall himself. However, it's also a constant source of confusion. That's because there is another popular rename command written in C, with a completely different syntax. It's understandable, of course. It's an obvious name. There are probably millions of shell scripts out there called rename.
The recurring problem for Linux enthusiasts like myself is that there are huge populations of users who believe that the rename command on their machine is the Linux rename command. Lots of rpm-based distros (e.g., Red Hat) include the C-ish rename, while many deb-based distros (e.g., Ubuntu) include the Perl-ish rename. Neither one explains this, they just give you a rename command, along with a man page showing how to use it. Naturally, everyone believes this is the same command everyone else has, so it's puzzling when an example that works perfectly for your friend on IRC doesn't work at all for you.
Whenever I spot a comment about "the rename command" I like to point out the existence of the other one. That was my first reaction when I spotted today's Perl Advent calendar, but since that doesn't have a facility for comments, I decided to write this instead. It's just as well, since that's not really a Linux entry. It's clearly talking about the Perl command. On the other hand, this problem doesn't just concern Linux folks. BSD folks (including OS X) may have one or the other rename command as well. The same goes for Windows folks running Cygwin.
Anyway, whenever you are talking about rename, keep in mind that some folks might assume you are talking about the Perl-ish rename found on CPAN, while other folks might assume you are talking about the C-ish rename found in util-linux. It's probably best to be explicit.
I am typing this on an Ubuntu 11.10 machine, which has both commands: rename is the Perl-ish one and rename.ul is the C-ish one. YMMV.
[1] Not to be confused with the Perl function or the Unix system call. Although this whole post is about such confusion, so maybe I should have mentioned it.

Posted by: |