是否可以这样做:
case $ans1_1 in
y)fedoraDeps;;
echo "something here";;
make -j 32;;
n)echo "Continuing"...;;
;;
*) echo "Answer 'y' or 'n'";;
esac
其中 fedoraDeps
是一个带有 yum
命令的函数。
我正在尝试用案例复制它:
if [[ $ans1_1 = y ]]; then
fedoraDeps
echo "something here"
make -j 32
elif [[ $ans1_1 = n ]]; then
echo "Continuing..."
:
else
echo "Answer 'y' or 'n'"
fi
最佳答案
;
或换行符用于结束命令。 ;;
用于结束case分支。只是不要尝试在每个命令后结束 case 分支,这很好:
case $ans1_1 in
y)
fedoraDeps
echo "something here"
make -j 32 ;;
n)
echo "Continuing"... ;;
*)
echo "Answer 'y' or 'n'" ;;
esac
关于bash - 一个案例中的多个命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21345381/