我编写了以下 bash 语句,但在执行时出现错误
case "$var1" in
*abc.com*)
data+="found abc.com"
;;
*)
case $Svar2 in
1*) if [[ "$value" == 113* ]] || [[ "$value" == 1122.168.52.* ]]
then
data+="value correctly set"
fi
;;
*)
2*) if [[ "$value" == 114* ]] || [[ "$value" == 115* ]]
then
data+="value correctly set"
fi
;;
*)
data+="value not set"
;;
esac
当我运行上述命令时,出现错误 syntax error near unexpected token
)'`
最佳答案
在 $Svar2
的第二种情况之前有一个额外的 *)
。
并且您缺少 case $Svar2
的 esac
语句。
case "$var1" in
*abc.com*) data+="found abc.com" ;;
*) case $Svar2 in
1*) if [[ "$value" == 113* ]] || [[ "$value" == 1122.168.52.* ]]
then
data+="value correctly set"
fi ;;
2*) if [[ "$value" == 114* ]] || [[ "$value" == 115* ]]
then
data+="value correctly set"
fi ;;
*) data+="value not set" ;;
esac ;;
esac
关于linux - bash case 语句中出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55749377/