每次我运行这个脚本时,它都会打印 0 然后中止并出现错误
./hw4_1: line 6: syntax error near unexpected token `let'
./hw4_1: line 6: ` let COUNTER=0'
资源:
#!/bin/bash
COUNTER=0
echo $COUNTER
for i in {$@:2}do
let COUNTER=0
while [COUNTER -ne $1]; do
echo "$i"
let COUNTER+=1
done;
done
exit
我已经尝试摆脱 let 并在 COUNTER 之前添加一个美元符号,但是这些东西的组合都不起作用......这种 bash 语法让我很生气。将 'let COUNTER=0' 更改为 COUNTER=0 只会返回错误
./hw4_1: line 6: syntax error near unexpected token `let'
./hw4_1: line 6: ` let COUNTER=0'