Check for null values in columns

Hi ,

I have below data with fixed with of 52 bytes having three columns value data.

01930 MA GLOUCESTER                                 
02033                                               
02025    COHASSET                                   
01960 MA                                             

I want if any of the column value is null .. i need to redirect that record into a seperate file

from above last three records should be stored into a seperate file

Regards
Sonu

you mean, you need to check whether 3 fields are there in the line or not ?

 
awk 'NF<3' input.txt > output.txt

What have you tried so far?... :rolleyes:

$ awk 'NF!=3' infile > outfile

Assuming as per your inputs - It is having only 3 columns....

awk '{ if ( NF == 3 ) { print > Old_file } else { print > new_file } }' file3