On 15/12/11 9:34 PM, Josh Dersch wrote:
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!
What is a glob but a regexp? And what is shell but a general purpose
programming language? And why have processes if you're not going to use
them?
For elegance, maybe you should write it all in C... Not to mention that
the 'elegant' solution (a 'ren' tool) was already given.
Wait, is elegant the word I want to use here? Hmm.
Since the thread started with the premise "DOS can do this but Unix
can't!!", elegance was going to be an unlikely theme.
And I'm pretty sure 'ad hoc' doesn't mean 'oh my god look at the
crystalline perfection of this'.
--T
- Josh
Insisting it's a "Unix" problem is like saying mammals have prickly
feathers.
--T