You can use Marcus's answer (* wildcards) outside a case statement, too, if you use double brackets:
(如果使用双括号,您也可以在案例语句之外使用Marcus的答案(*通配符) :)
string='My long string'
if [[ $string == *"My long"* ]]; then
echo "It's there!"
fi
Note that spaces in the needle string need to be placed between double quotes, and the *
wildcards should be outside.
(请注意,针线中的空格必须放在双引号之间,并且*
通配符应位于外部。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…