in reply to Accessing Tab Delimited Field in Perl One-Liner

perl -ane'$F[1] || print'

Replies are listed 'Best First'.
Re^2: Accessing Tab Delimited Field in Perl One-Liner
by aufflick (Deacon) on Jun 01, 2009 at 01:42 UTC

    Dang, -a/-F was what I was forgetting.

    For anyone who, like me, constantly forgets the commandline arguments, perldoc perlrun is your friend.

Re^2: Accessing Tab Delimited Field in Perl One-Liner
by Marshall (Canon) on Jun 01, 2009 at 19:39 UTC
    Just another way if you forgot about -a (autosplit), slightly longer, but is runnable code within a script...
    perl -ne "(split)[1] || print" temp.txt #same thing... perl -ne "print if !((split)[1]);" temp.txt
    A Perl variable evaluates to false if either: undefined, numeric zero or "" (empty string).

    Update: also of note: default split operates on whitespace which is (\s\t\f\r\n). Above would work fine with combination of spaces and tabs between tokens.