如何檢查字符串是否包含Bash中的子字符串我在巴什有一根繩子:string="My string"如何測試它是否包含另一個字符串?if [ $string ?? 'foo' ]; then
echo "It's there!"fi哪里??是我未知的接線員。我用回聲和grep?if echo "$string" | grep 'foo'; then
echo "It's there!"fi看起來有點笨拙。
添加回答
舉報
0/150
提交
取消