Assuming that dst_dir
and drp_dir
are two output files you want to create, the following awk
program will do that for you.
awk '
NF {
data = substr ($0, 1, 14)
count = gsub (/0/, "", data)
print > (count==12 ? "dst_dir" : "drp_dir")
}' file
Using NF
we skip the blank lines. We create a subset of your line using substr
function. gsub
returns the number of substitution made, so we capture the return value to variable count
.
Lastly, we test if the count
is 12. If it is we write the record to dst_dir
else we write the record to drp_dir
.