On Wednesday 19 Aug 2009, steve wrote:
> [asnip]
> b. Learn a scripting language (I'd recommend python) --
> http://wiki.python.org/moin/BeginnersGuide
Just playing Devil's Advocate here, but the day I start recommending
Python as a scripting language is the day it lets me do something like
this from a command-line:
perl -e 'undef$/;$"=chr(10);foreach(@ARGV){open(F,$_);
$l=<F>;@l=reverse(split(/\n/,$l));close(F);open(F,">$_");print F
"@l";close(F);}' file1 file2 file3...
[Don't try this in a directory where you have files valuable to you: it
reverses the lines in the files whose name you provide on the command
line. On the other hand, if you run it twice the files are back to
their original stage (I think :) ]
You'd be surprised how may of these semi-complex one-liners I've used to
get Real Work done, both personally and for clients (e.g. I remember
when the client wanted a quick list of all the IP addresses that had hit
his site more than 50 times from logs spread over a thousand files, and
the list of URLs they had hit). Yup, you got it -- Perl one-liner!
I must admit there's a downside to this: if you use Perl you can't
charge the client a bomb for developing an application which will do the
same task in 1000 lines of beautifully indented and commented code --
not because you can't write that in Perl, but because it seems such a
waste when one line is enough ;)
Regards,
-- Raju
--
Raj Mathur [email protected] http://kandalaya.org/
GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/ || It is the mind that moves
--
http://mm.glug-bom.org/mailman/listinfo/linuxers