While loop subshell problem

People,

Here is my code

while read ln
do
xyz=$(echo $ln/$val1*100-100|bc -l|xargs printf "%1.0f\n")
if [ "$xyz" -le -50 ] && [ "$xyz" -ne 0 ]; then
                iam="YELLOW"
fi
done <<< "$(grep "^[0-9]" $TMPOUT)"

where $TMPOUT is a flat file which contains a set of values.

Whilst executing the above, I get an error

ABC.ksh: line 136: unexpected EOF while looking for matching `"'
ABC.ksh: line 141: syntax error: unexpected end of file

Where is the problem, how i can correct it. Please help, thanks.

One reason could be, you need to escape the asterisk:

xyz=$(echo $ln/$val1\*100-100|bc -l|xargs printf "%1.0f\n")

Guru.

You are trying to put double quotes inside double quotes, try using single quotes:

'^[0-9]'

The double quotes usage is fine. That's one of the benefits of the $(...) command substitution syntax. The code within the substitution does not have to worry about colliding with anything in its surroundings.

I suspect the error lies elsewhere. The OP is only showing us 7 lines but the diagnostic messages indicate that there are well over a 100 in the script.

To the OP, line numbers in error messages can be misleading. I suggest posting the entire script.

Regards,
Alister

Ah, yes, good point. A runaway quote can eat up all the lines after it until it finds another quote.