#!/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
Read More:
- SSM project interceptor infinite loop error [How to Solve]
- How to Solve forEach cannot exit the loop Issue
- The loop of life and death occurs when the El table component of element UI is bidirectional bound
- [Solved] The Shell Script error: syntax error: “(” unexpected “)
- [Solved] SHELL Run Error: “-BASH: ./TEST.SH: /BIN/BASH^M: BAD INTERPRETER: NO SUCH FILE OR DIRECTORY”
- file_name.sh: 3: Syntax error: “(“ unexpected [How to Solve]
- [Solved] error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
- [Solved] Docker Error: bad interpreter: Permission denied
- [Solved] pagehelper Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LIMIT 1’
- Jenkins reported an error when running the docker permission in the shell script
- [Solved] Adb Shell Monkey Warning: can‘t create log.txt, Read-only file system
- ‘pre-mature EOF‘ : syntax error syntax error [How to Solve]
- Vs code execute command error [How to Solve]
- [Solved] Git error: bad signature 0x00000000 fatal: index file corrupt
- Visual Studio 2012 error C4996: ‘scanf’: This function or variable may be unsafe.
- [Local Precompilation Error] do not set execute permissions for source files
- [Solved] At least one of these environment variable is needed to run this program
- [Solved] tsc execute error in VSCode Terminal
- [Solved] Opencv Call yolov3 Error: IndexError: invalid index to scalar variable
- Angular_ Error: Cannot assign to a reference or variable!