Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

shell: search a string if it contains another string

# Search for a substring in another string using wildcard

string='My long string'
substr='My long'

# Note: the wildcard character (*) is outside the double qoute ("")
if [[ "$string" == *"$substr"* ]]; then
  echo "Found substring!"
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #search #string #string
ADD COMMENT
Topic
Name
4+5 =