I'm trying to call this shell script from within the CLI of GRASS GIS:
for (( day=5; day<367; day+5 )); do
# commands that I've tested without a loop.
done
exit 0
returns
Syntax error: Bad for loop variable
Perhaps GRASS GIS pre-defines a variable named "day"? The code doesn't work in straight bash by the way. You don't actually increment the value of "day".
That works for me, bash 2.05b on a RHEL 5.0 server. |
|||||||
|
This error message comes from ash. There are several shells with a similar syntax. Ash is a relatively basic one designed for a small memory footprint and fast execution. Another common shell is Bash. Bash has more features. The syntax you posted exist only in bash (and some other shells, but not ash). In ash, you would need to write¹:
Note that depending on the Linux distribution, ¹ Assuming you meant |
|||
|
Would this work better?
|
|||||||
|
day+=5
Good luck. – shellter May 18 '12 at 19:49