Actualmente estoy escribiendo un script bash. Tengo dos comandos if. Realmente no puedo describir el problema aquí, así que describiré mi problema en códigos.
#!/bin/bash
echo -e "What is the SGID?"
read Cevap50
if [ ! -f /home/fixscript/AudioBot$audiobot_port/.adminlikler_sgid_silmeyin ]
then
rm -rf .rights.toml
touch .adminlikler_sgid_silmeyin
echo -ne "$Cevap50" >> .adminlikler_sgid_silmeyin
adminlikler_sgid=`cat .adminlikler_sgid_silmeyin`
rights_bir
echo " groupid = [ $adminlikler_sgid ]" >> .rights.toml
echo ' # And/Or your admin Client Uids here' >> .rights.toml
elif [ ! -f /home/fixscript/AudioBot$audiobot_port/.adminlikler_uid_silmeyin ]
then
echo " useruid = []" >> .rights.toml
rights_iki
clear
else #There is the problem, this else should affect line 14th's if. But it just effects both of them.
#Some Codes
else #This else should affect line 5th's if.
Respuesta1
Piense en if elif y else como eslabones de una cadena, if es el comienzo, elifs son los eslabones del medio y else es el eslabón final. Lo que has escrito es "principio, enlace medio, enlace final, enlace final". Para separar los if en las líneas 5 y 14, lo que busca es if anidado.
Entonces mi sugerencia sería así.
#!/bin/bash
echo -e "What is the SGID?"
read Cevap50
if [ ! -f /home/fixscript/AudioBot$audiobot_port/.adminlikler_sgid_silmeyin ]
then
rm -rf .rights.toml
touch .adminlikler_sgid_silmeyin
echo -ne "$Cevap50" >> .adminlikler_sgid_silmeyin
adminlikler_sgid=`cat .adminlikler_sgid_silmeyin`
rights_bir
echo " groupid = [ $adminlikler_sgid ]" >> .rights.toml
echo ' # And/Or your admin Client Uids here' >> .rights.toml
else #Effects line 5's if.
if [ ! -f /home/fixscript/AudioBot$audiobot_port/.adminlikler_uid_silmeyin ]
then
echo " useruid = []" >> .rights.toml
rights_iki
clear
else # Effects line 15's if