#!/bin/bash
if [[ $1 = 'tomcat' ]];
then
echo "Input is tomcat"
else if [[ $1 = 'redis' ]] || [[ $1 = 'zookeeper' ]];
then
echo "Input is $1"
else
echo "Input Is Error."
fi
出现报错:
[oracle@standby ~]$ ./ts01.sh zookeeper
./ts01.sh: line 12: syntax error: unexpected end of file
备注:发现执行是错误的,经过查看可以知道,shell脚本中不是else if而是elif这个写法
#!/bin/bash
if [[ $1 = 'tomcat' ]];
then
echo "Input is tomcat"
elif [[ $1 = 'redis' ]] || [[ $1 = 'zookeeper' ]];
then
echo "Input is $1"
else
echo "Input Is Error."
fi