awk '$4 ~ /T/ { print $1 }'
perl -nE '@x = split /\s+/; say $x[0] if $x[3] =~ /T/;'
... stares at this and wonders ... reads `man perlrun` ... Oooh, there's a switch to auto-split-on-whitespace in Perl. perl -anE 'say $F[0] if $F[3] =~ /T/;'
Sooo this doesn't quite answer your question anymore, but I'm going to leave this here since it's a nice instance of TIL.That and maybe because i'm an old perl die hard, its just easier to pipe to perl than remember how awk does its shenanigans.
The nice thing about the @F array is that @F[0] doesn't represent the whole record.
There is a class of Awk bugs whereby arithmetic is being done on the parameters using $N (where N is some calculated variable containing an integer). Everything is fine when N >= 1, but if there is a bug where N is accidentally zero, then $N refers to the whole record instead of throwing an out-of-bounds error.
And things are accidentally zero quite easily in awk, e.g.
awk '{print $X}' # X is undefined so serves as zero; this prints all linesHowever, on the same OS, "nawk" does.
I've long since had to deal with Solaris but for about 10 years of Solaris I always treat awk with a lowest common denominator approach. Which means I tend to avoid it even to this day.
> perl -anE 'say $F[0] if $F[3] =~ /T/;'
^
^
Please tell me that isn't required. Fail! txr -e '(awk ([#/T/ [f 3]] (prn [f 0])))'
-e is just "evaluate Lisp expression for side effects; don't print its value"
And despite having a strong affinity for Perl, I don't think it's productive to just bannish Awk to the trash: part of being well-rounded is knowing many tools—which can overlap to some degree—and appreciating the sweet spot of each one. For some one-liners, Awk is just as (if not more) elegant as Perl.