On CentOS, the rename command uses two simple strings, from and to.

rename from to file...

while on Debian/Ubuntu it uses a perl-style regular expression.

rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

Why does this utility differ based on the distribution? Is there a reference for which distributions ship or default to which versions of the utility?


History. There are two historical lines of a rename command, with the same basic purpose but completely different syntax and capabilities:

  • The rename command in the util-linux package. It appeared in version 2.10e and the program is dated 2000-01-01.
  • A perl script, which was distributed with Perl as an example program. The Debian changelog records it being added to Debian in June 1999 (the program itself dates back to at least 1992). Another version, which is backward compatible, comes with Unicode::Tussle (as of Debian jessie, it's called file-rename, and provided in the rename package; some other distributions call it prename).

On the one hand, util-linux is a core package, so it's more standard than the Perl example script which was included at Debian's whim. On the other hand, the Perl script was in Debian first. So far, Debian has chosen to preserve compatibility with past Debian release, rather than align with other distributions. Distributions derived from Debian (Ubuntu, Mint, elementary, etc.) tend to follow Debian on this point.

Other distributions didn't have a rename command when one was added to util-linux, so they naturally include the util-linux version.

  • /usr/bin/rename is not part of any package. At least dpkg -S /usr/bin/rename does not return anything. – Faheem Mitha Apr 9 '16 at 1:40
  • 1
    @FaheemMitha It's a symlink to /etc/alternatives/rename, which defaults to the Perl version (but can point to the util-linux version instead, at the choice of the administrator). – Gilles Apr 9 '16 at 1:45
  • @FaheemMitha That's because /usr/bin/rename is controlled by debian's alternatives system. try update-alternatives --display rename. debian allows the local sysadmin to choose between util-linux or perl rename (or others, if any exist) – cas Apr 9 '16 at 1:46
  • hmmm, that's odd. on my sid system, util-linux doesn't provide an alternative for /usr/bin/rename. but another package rename does, so the choices are /usr/bin/prename from perl (priority 60) or /usr/bin/file-rename from rename (priority 70). file-rename seems to be an updated/enhanced version of prename. – cas Apr 9 '16 at 1:53
  • @cas file-rename is the Unicode::Tussle version. I think the reason rename.ul isn't an alternative for rename is because it's incompatible; but an administrator who favors consistency between distributions can still manually change the link to point to /usr/bin/rename.ul. I don't know if this would break any Debian scripts; in principle, according to policy, packages can count on the perl version if they depend on perl, and build scripts can count on the perl version since the perl package is build-essential. – Gilles Apr 9 '16 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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