我想跳到Bash脚本的开头。有什么简单的方法可以做到这一点吗?
#start
echo "Start"
read -p "Input: " i
if [ i = j ]
then
z=1
elif [ i = n ]
then
#jump to start
elif [ i = x ]
then
exit
fi
发布于 2020-04-01 09:16:42
尝试:
#start
while true; do
echo "Start"
read -p "Input: " i
if [ $i = $j ]
then
z=1
break
elif [ $i = $n ]
then
continue #jump to start
elif [ $i = $x ]
then
exit
fi
done
#you will arrive here when i = j
发布于 2020-04-01 09:34:07
我真的不能确定代码的目的,但我认为这样的东西可以让你理解发生了什么:
inputvar=""
while [[ "$inputvar" != "x" ]]
do
#start
echo "Start"
read -p "Input: " inputvar
if [ "$inputvar" = "j" ]
then
echo "input equals j"
elif [ "$inputvar" = "n" ]
then
echo "input equals n"
fi
done
echo "input equals x"
https://stackoverflow.com/questions/60967276
复制相似问题