Answers for "bash if substring"

1

bash if substring

string='Hi substring' #To check if string has "Mylong" substring do
if [[ $string == *"substring"* ]]; then
  echo "String has substring"
fi
Posted by: Guest on May-26-2021
3

checking if a substring exists in a string bash

string='Haystack';

if [[ $string =~ "Needle" ]]
then
   echo "It's there!"
fi
Posted by: Guest on April-06-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language