[英]How to fix error bash unexpected token bash?
I need an important help with my bash code, I have been in this state like this for 1 hour and I did not get anywhere, I solved the end of code error, but now I am in that and I am not able to advance, prove changing elif by else if but still I did not find a solution help.我的 bash 代码需要一个重要的帮助,我已经在这个 state 中待了 1 个小时,但我没有得到任何地方,我解决了代码错误的结尾,但现在我在其中,我无法前进,证明通过 else if 改变 elif 但我仍然没有找到解决方案帮助。 Thanks.谢谢。
Error code: line 39 (19 after edit): syntax error near unexpected token `elif'错误代码:第 39 行(编辑后第 19 行):意外标记“elif”附近的语法错误
echo -e '\e[31m[ 1 ] Instalar paquetes\e[1m'
sleep 0.1
echo -e '\e[31m[ 2 ] Instalar Herramientas\e[1m'
sleep 0.1
echo -e '\e[31m[ 3 ] Eliminar Herramienta\e[1m'
sleep 0.1
echo -e '\e[31m[ 4 ] Info\e[1m'
sleep 0.1
echo -e '\e[31m[ 5 ] Salir\e[1m'
sleep 0.1
echo ' '
echo -e '\e[34mInserte la opción que desea utilizar:'
read vw
if [ $vw = 1 ];
then
sleep 1.3
echo 'Inserte el nombre del paquete que desea instalar ej.python'
read instalar
pkg install $instalar
elif [ $vw = 2 ];
then
sleep 1.3
bash tools.sh
fi
elif [ $vw = 3 ];
then
sleep 1.3
echo 'inserte el nombre de la herramienta que desea eliminar:'
read eliminar
rm -rf $eliminar
fi
elif [ $vw = 4 ];
then
sleep 1.3
echo 'Autor: '
fi
elif [ $vw = 5];
then
sleep 1.3
fi
else
echo 'Por favor inserte un numero del que se encuentra en la lista'
sleep 4
bash chesthacker.sh
exit 0
fi
fi
elif [ $vw = 3 ];
This is incorrect, If you finished if block with fi , you can't start new block with elif .这是不正确的,如果你用fi完成了if块,你不能用elif开始新的块。 The correct syntax is:正确的语法是:
if ...
then
elif ..
then
elif ...
then
else
fi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.