4

Проверяем нахождение подстроки в строке

string='My string';
 
if [[ "$string" == *My* ]]
then
  echo "It's there!";
fi
 
needle='y s'
if [[ "$string" == *"$needle"* ]]; then
  echo "haystack '$string' contains needle '$needle'"
fi
It's there!
haystack 'My string' contains needle 'y s'
-----------