in reply to Re: AWK and Perl on UNIX
in thread AWK and Perl on UNIX
I still find that, after all these years, it's easier to write
ls -l|awk '{print $5}'than
ls -l|perl -alne 'print $F[4]' or Newton forbid... ls -l|perl -ane 'print "$F[4]\n"'Not only is the awk solution clearer, it also has a lighter resource footprint.
That is, when you string together long pipes on the command line, awk is often more compact than Perl. That's about all I use awk for these days, but I sure used to sling around a lot of data with it in the 80s.
It's not difficult to learn to write baby awk, and if you do it will serve you well. If the job gets too tough, though (think: you can no longer run it from the command line) then it's time to switch to Perl.
For example, user functions were retrofitted into the language, and the syntax is a bit of a botch. I can't even remember what it was now, but there was a gotcha that would rear its head up every so often and bite you.
Just because you have a chainsaw doesn't mean you can't use a pair of secateurs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: awk has its place
by davorg (Chancellor) on Mar 30, 2001 at 19:38 UTC | |
by grinder (Bishop) on Mar 30, 2001 at 19:51 UTC |