Unix: Read file line by line conditionally Unix: Read file line by line conditionally unix unix

Unix: Read file line by line conditionally


The following should work

awk -F',' '(NF==1){print $0}' input_file

Set the record separator to comma with the -F flag and then only print the whole line $0 when the number of fields NF equals 1

Or in short as pointed out by @nu11p01n73R

awk -F, 'NF==1'


Just skip the lines which has a comma.

awk '!/,/' file


grep would be sufficient:

fgrep -v , file

Output:

aaaaddddkkkk