gpt4 book ai didi

bash - 一个案例中的多个命令?

转载 作者:行者123 更新时间:2023-11-29 08:56:09 25 4
gpt4 key购买 nike

是否可以这样做:

 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com