9951 explained code solutions for 126 technologies


bashCheck if a string contains a substring


string="Haystack with a needle"
if [[ $string == *"needle"* ]]; then echo "Found"; fictrl + c
string="Haystack with a needle"

test string to search in

"needle"

substring we're searching for in a test string

echo "Found"

replace with any code that should be executed if the string contains required substring