#!/bin/bash
for ((i = 10 ; i>=0 ; i--))
do
echo $i
done
Syntax error: bad for loop variable
The reason is that since Ubuntu 6.10, Ubuntu has replaced the previous default bash shell with dash shell; It shows that the/bin/sh link reverses/bin/dash instead of the traditional/bin/bash.
Question 1: why #/ Bin/bash doesn’t work?
./execution will read #/ Bin/bash specifies the shell parser, and the script needs execution permission
Executing with SH will not read #/ Bin/bash, which is equivalent to executing the/bin/sh shell script and passing it in as a parameter. The script does not need execution permission, but only reading permission
Solution 1:
Execute sudo dpkg reconfigure dash and select No
Solution 2:
Modify cycle
for i in `seq 1 10`
do
echo $i
done
OR
for i in {0..10}
do
echo $i
done