Filter fields with space character from csv file on command line

command-line-interfacecsvunix

A csv file with multiple records is delimited by |.

field1|field2|field3|field4|field5

I want to check if field3 is blank or contains "space" characters only.
If it is blank or space, the whole line should show up.

Best Answer

$ echo "1|2||4" | awk  -F'|' '$3 ~ /^[ \t]*$/   {print $0}'

1|2||4

$ echo "1|2|  |4" | awk  -F'|' '$3 ~ /^[ \t]*$/   {print $0}'

1|2|  |4

$ echo "1|2|  3|4" | awk  -F'|' '$3 ~ /^[ \t]*$/   {print $0}'