gpt4 book ai didi

regex - bash + 减少比较线到短路径

转载 作者:太空狗 更新时间:2023-10-29 11:27:19 25 4
gpt4 key购买 nike

我想将下面的比较线缩短为短线

   [[ $ANSWER = YES ]] || [[ $ANSWER = yes ]] || [[ $ANSWER = Yes ]] && echo your answer is really yes

所以我尝试了以下但没有成功

[[ $ANSWER = ([YES|Yes|yes]) ]] && echo your answer is really yes
[[ $ANSWER = [YES|Yes|yes] ]] && echo your answer is really yes

请指教正确的方法是什么?

最佳答案

shopt 允许您更改 shell 行为

shopt -s nocasematch
[[ $ANSWWER = "yes" ]]

shopt - bash reference

关于regex - bash + 减少比较线到短路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24752120/

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