I am having a "|" delimited flat file and I have to pick up all the records with the 2nd field having null value. Please suggest.
nawk -F'|' -v OFS='|' '!$2' myFile
vgresh,
can u explain the code. I understood that we defined | as the delimiter but can u explain the remaining steps?
Thanks
nawk -F'|' -v OFS='|' '!$2' myFile
-F'|' - define '|' as the INPUT field separator
-v OFS='|' - define '|' as the OUTPUT field separator
'!$2' - can be re-written as '$2 == ""' OR easier to understand '$2 == "" {print }'
[all of which achieve the same].