Use awk to pipe output from one file into multiple
Hi All. Thanks for your help in advance.
I have a requirement to examine the number of delimiters in each record of a file. If the record has the expected number of delimiters it should be passed into a 'good' file. If it does not, the record should be passed into a 'bad' file. I have been able to complete this task, but it requires passing over the file twice. With bigger files this may slow down performance. I currently am using:
cat ${landing_dir}/${lfile}|awk -F "${file_delimiter}" "NF !=${file_field_count} {print NR, \$0 }" >> $bad_file
The similar code is used for the 'good' file with slight modifications. Is there a way to do this in only one pass over the file?
Thanks, again!
|