In article <4EEAAE4D.7070609 at mail.msu.edu>,
Josh Dersch <derschjo at mail.msu.edu> writes:
On 12/15/2011 5:21 PM, Toby Thain wrote:
But in any ahem Unix system, you can already do, ad hoc:
$ ls | perl -n -e 'chomp; m/(.*)\.log$/ && rename($_,
"$1.old");'
Use 'find' to do it recursively, of course (try doing *that* in DOS).
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!
Wait, is elegant the word I want to use here? Hmm.
I would have done (csh)
foreach f (*.log)
mv $f `basename $f .log`.old
end
sh variants work as well. I think using basename is much more
readable than piping into perl and using perl to do the rename.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 version available for download
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
Legalize Adulthood! <http://legalizeadulthood.wordpress.com>