i=0 for f in `awk '{print $1}' config.list` do echo "i value is $i" if ["$i" = "0"] then echo "here" i=$((i+1)) continue fi arr[i]=$fi=$((i+1)) done
在上面的bash脚本中,我得到了一个错误,我使用if语句,看起来像这样
./script.sh: line 5: [0: command not found
请指出我可能是我的错误。
if [ "$i" = "0" ]
在bash中,在if
条件下需要[
和]
周围的空格
你得到这个错误,因为Bash if语句需要在操作数周围增加空格:
if [ "$i" = "0" ]