我在做bash,我試着測試給定變量x中的子字符串「world」。我有一部分代碼工作。但另一個不工作。我想弄清楚爲什麼bash substring正則表達式匹配通配符
第一個是工作
x=helloworldfirsttime
world=world
if [[ "$x" == *$world* ]];then
echo matching helloworld
第二個是不工作
x=helloworldfirsttime
if [[ "$x" == "*world*" ]];then
echo matching helloworld
如何讓第二個工作,而無需使用變量,如第1種方法
有人可以爲我解決第二個問題..謝謝