On 16/12/11 4:16 AM, Eric Smith wrote:
Josh Dersch wrote:
Wow, that's so elegant. It only requires
spawning two
processes, piping to a general purpose programming
language, and using regexps to make it work!
Bear in mind that a big part of the Unix philosophy is that rather than
providing tools that directly do anything you might need, Unix (and
associated software) are intended to give you simple tools that you can
combine, ...
I'll have to agree with you that the given solution is
inelegant. I would say that anything that involves the use of Perl is by
definition inelegant. That's spoken by someone who has once written a
non-trivial piece of software in Perl, and lived to regret it.
Personally I use a shell for loop with mv and basename, like:
for f in *.foo; do mv $f `basename $f .foo`.bar; done
That's better. If I had to do this kind of operation more than once
every four years I'd have a better chance of arriving at it :)
--Toby
That won't work when you want to change something other than the suffix
of a file, ...
Eric