Reputation: 1102
How do I do this in bash:
while (var1 < (var2 - 1)) {
...
}
Right now, this is what I have in bash:
while [ $var1 < $var2-1 ]
do
...
done
Upvotes: 2
Views: 284
Reputation: 781726
Use double parentheses to make an arithmetic statement.
while ((var1 < (var2 - 1)))
do
...
done
Upvotes: 7
Reputation: 111
since
a=2; b=3; [ $a -gt $(($b-1)) ] && echo yes || echo no
then the script would be like
while [ $var1 -lt $(($var2-1)) ]; do
...
done
Upvotes: 0