I am trying to run a bash script like so:
#!/bin/bash
set i=1991
while [ $i -le 2017 ]
do
echo "looping and doing stuff"
$i++
done
echo all done
I get the following error:
[: -le: unary operator expected
I have also tried changing the code like so:
#!/bin/bash
set i=1991
while (( $i <= 2017 ));
do
echo "looping";
(( $i++ ));
done
echo ALL done
which gives me this error:
((: <= 2017 : syntax error: operand expected (error token is "<= 2017 ")
and I've tried this:
#!/bin/bash
set i=1991
while [ "$i" -le "2017" ]
do
echo "looping"
$i++
done
echo ALL done
And I get this:
[: : integer expression expected
I think it's a stupid syntax error but unfortunately I can't seem to figure it out. My version of bash is 4.3.48.
Thank you!