Created
March 8, 2017 00:02
-
-
Save atomize/5ce556626d3272b8d32578cb3b3135f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String contains string | |
stringContains() { [ -z "${2##*$1*}" ] && [ -z "$1" -o -n "$2" ]; } | |
# Used like so | |
SRC_STRING="this is a sample string where TEST we want to check for the word 'TEST'" | |
if stringContains "TEST" "$SRC_STRING"; then | |
echo "Found TEST in SRC_STRING" | |
else | |
echo "Couldn't find TEST in SRC_STRING" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment