I have the following code in a shell script: to count the number of columns first (variable numCol), then plug it in the for-loop in the awk to check if all the values are all 0s in each line:
numCol=$(awk '{print NF}' $line | head -n 1)$
awk '{for (i=1; i<=$numCol; ++i) if($i != 0) {print;next}}' $line$
but, I got this error: awk: illegal field $(), name "numCol"
awk '/[^0[:space:]]/' "$line", assuming$linecontains the name of an input file as it appears to from your script.printf "%s\n" 0 0.0 0e0 0e-1 | awk '$1 != 0'all equal to zerothough, he saidall 0sso I think my suggestion would work. Some sample input and expected output would tell us for sure.$at the end of each line is puzzling; I think they should not be present.