I’m using a GNU/Linux distribution where the utility rename
comes from util-linux
and I want to make full use of regular (Perl or POSIX) expression
Here is the manual page: http://linux.die.net/man/1/rename. It is pretty straightforward:
rename from to file...
rename will rename the specified files by replacing the first occurrence of from in their name by to.
I believe there are no regexes, it is just plain substring match.
The following command gives the expected result with your input file but using the perl
version:
rename 's/foo_\D+(\d+)/foo_$1/' *.ext
You can test the command using -n
option to rename