Reputation: 873
I wrote small bash script
for (( j=10;j<20; j++ ))
do
./b5 $j $[ $1 * 3 ]
done
Which should execute program b5 and send two parameters, $j and $1 multiplied by 3.
When I try to run it, i get:
* 3 : syntax error: operand expected (error token is "* 3 ")
How should one do it?
Upvotes: 0
Views: 1411
Reputation: 873
To be honest, both options work:
but he problem was $1 was not initialized. My mistake.
Upvotes: 1
Reputation: 14949
You have to use $((..))
for doing arithmetic expression.
Instead,
./b5 $j $[ $1 * 3 ]
to
./b5 $j $(($1 * 3))
Upvotes: 1