News for hackers. Stuff that matters.
Re:Interesting commands for the Linux shell by cutler on Thursday September 14, 2017 @06:30AM (#15246526)
CentOS 7 specifies `man rename` : rename [options] expression replacement file...

The rename example fails with "rename: not enough arguments".

Re:Interesting commands for the Linux shell by jwilk on Thursday September 14, 2017 @07:12AM (#15246765)
Unfortunately, there are two incompatible rename programs in the wild. :(

Debian ships this: https://metacpan.org/pod/distribution/File-Rename/rename.PL

Most(?) other distros ship the one from util-linux: http://man7.org/linux/man-pages/man1/rename.1.html

Re:Interesting commands for the Linux shell by loudmax on Thursday September 14, 2017 @08:31AM (#15247271)
Don't read it like this: rename <expression> <replacement file> ...

Read it like this: rename <expression> <replacement> <file(s)...>

Argument 1 is a string (not a regex), argument 2 is string to replace the old string, and arguments 3+ is a file, or list of files, or a glob.

The man page includes a warning about the lack of safeguards. It is unfortunate that rename doesn't have an equivalent of mv or cp's -i flag because it's so easy to overwrite files if your expressions aren't exactly correct.

On some Ubuntu systems, I've seen another version of rename that's actually a Perl script that uses regular expressions. I think that version lets you set some safeguards, which are sorely lacking in the binary version of rename that ships with CentOS.

Re:Interesting commands for the Linux shell by wyoh on Friday September 15, 2017 @03:03AM (#15255213)
It's available in Fedora under the name "prename". I've asked the maintener to make it available for EPEL 7, will this work for you?