in reply to Awk and Perl unique features

Somehow, I find awk '{print $3}' easier to type/remember than perl -anle 'print $F[2]'. That's about the only case I use awk for nowadays - and then I only use it in shell one-liners.

Of course, if I have to write a program in an environment that doesn't have perl available, I'd use awk. But last time that happened is a few years ago.

Replies are listed 'Best First'.
Re^2: Awk and Perl unique features
by Fletch (Bishop) on Apr 16, 2010 at 14:26 UTC

    That's why you setup your shell with abbrevs and all you have to type is ,p2 or what not to have it expanded into | perl -lane 'print $F[2]' for you when you hit the space key.

    (OK, technically I have ,2 which expands to | awk '{print $2}' which I use more often out of habit; but I've also got ,pa which expands out to | perl -lane, and thinking it over during the reply I may try making one that expands to | perl -lane 'print $F[~]' where the ~ is where the cursor is left after expansion a la TextMate snippets)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.