linux shell脚本syntax error near unexpected token `then'

       1 #!/bin/sh
      2 if["$SHELL"="/bin/bash"];then
      3    echo "your login shell is the bash(bourne agein shell)"
      4 else
      5    echo "your login shell is not bash but $SHELL"

      6 fi


今天编写了一个简单的shell脚本,执行时报错syntax error near unexpected token `then',

最后才发现:if和[之间一定要有一个空格,添加上之后执行正常。

猜你喜欢

转载自blog.csdn.net/nui111/article/details/50628185