Extract Lines when Column K is empty with AWK/Perl

后端 未结 3 1841
一生所求
一生所求 2021-02-19 04:23

I have data that looks like this:

foo 78 xxx
bar    yyy
qux 99 zzz
xuq    xyz

They are tab delimited. How can I extract lines where column 2 is

3条回答
  •  温柔的废话
    2021-02-19 04:57

    perl -F/\t/ -lane 'print unless $F[1] eq q//' myfile.txt
    

    Command Switches

    • -F tells Perl what delimiter to autosplit on (tabs in this case)
    • -a enables autosplit mode, splitting each line on the specified delimiter to populate an array @F
    • -l automatically appends a newline "\n" at the end of each printed line
    • -n processes the file line-by-line
    • -e treats the first quoted argument as code and not a filename

提交回复
热议问题