我正在进行bash编程,尝试测试给定变量x中是否包含子字符串"world"。我的一部分代码可以工作,但另一部分却不行。我想找出原因。
第一部分可以工作。
x=helloworldfirsttime
world=world
if [[ "$x" == *$world* ]];then
echo matching helloworld
第二个不起作用。
x=helloworldfirsttime
if [[ "$x" == "*world*" ]];then
echo matching helloworld
如何在不使用类似第一种方法的变量的情况下使第二种方法正常工作
能有人帮我修复第二个方法吗..谢谢