Hi guys,
I am writing a simple bash script looking like this:
LOOP1
Code:
#!/bin/bash
...
echo $OUTPUT | awk '{
for (i="'"$NRCORES"'";i<="'"$ENDLOOP"'";i++)
print $i
}'
My problem is that the script doesn't output anything
BUT !
If I change it to the following:
LOOP2
Code:
#!/bin/bash
echo $OUTPUT | awk '{
for (i=8;i<=17;i++)
print $i
}'
It gives me what it is supposed to give (the 8-th to 17-th column of the $OUTPUT variable)
Strangely, if
I echo $NRCORES or $ENDLOOP in the script I get 8 and 17 respectively, so in my view LOOP1 is exactly the same as LOOP2. However, awk doesn't seem to agree with me. In addition, I know for sure that when awk encounters a non-numeric variable in the print statement, it will take it as a zero and print the whole string. Therefore, I don't see what the problem can be.
WHAT IS WRONG WITH IT ?
please respond