I have a long CSV file with two rows for each entity and I want to print
only the first row to the output file. It's so simple that despite my
research in using awk I'm not seeing my error.

Gawk script:

#!/usr/bin/gawk

BEGIN { FS=OFS="," }
{ if ($5 ~/'Legal Contact'/) # double quotes also fail
        next
  else
        print $0
}

The script also fails my expectation if the if statement is
        if ( $5 == "Legal Contact" )

Sample input file:

'fld1','fld2','fld3','fld4','fld5'
'fee','fie','foh','fum','Keep Me'
'fee','fie','foh','fum','Legal Contact'

The output I want is only the first line, but both lines are printed to the
output file. What simple thing am I missing?

TIA,

Rich
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to