Skip to content

Instantly share code, notes, and snippets.

@Olical
Created June 30, 2011 16:00
Show Gist options
  • Save Olical/1056537 to your computer and use it in GitHub Desktop.
Save Olical/1056537 to your computer and use it in GitHub Desktop.
Check if a string contains another string using a regular expression in bash
string='My string';
if [[ $string =~ .*My.* ]]
then
echo "It's there!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment