I know I'm missing something very obvious, but I just can't see it. In the code below, new_i
variable gets incremented properly, however, when I get to the if
statement, I think my syntax is off. I looked at some examples, but none show variable set to zero when if
statement is greater than (in this case 15
) a number.
#!/bin/sh
i=$(cat /etc/hour.conf)
new_i=$((i+1))
if [[ "$new_i" -gt 15 ]]; then
new_i=0
fi
echo "$new_i">/etc/hour.conf
echo "$new_i"
When I run this script I get the following error:
./loops: 3: ./loops: Illegal number: new_i
Thanks in advance for your help!