2019-07-22 16:16:43 -0600, Assaf Gordon: [...] > or the more robust: > > printf "%s" "$variable_i'm_looking_in" | grep -q "$thing_i'm_looking_for" [...]
Preferably (POSIXly): printf "%s\n" "$variable_i'm_looking_in" | grep -qe "$thing_i'm_looking_for" Or printf "%s\n" "$variable_i'm_looking_in" | grep -q -- "$thing_i'm_looking_for" That is add a newline character so grep's input is valid text and guard against "$thing_i'm_looking_for" starting with -. [...] > Use something like: > > if echo "$mailServ" | grep -q "google.com"; then > printf "%s uses google for mail \n" $mailServ > fi [...] Note that it matches on googleXcom as well as "." is a regexp operator (I see you made that note later one). Use grep -q 'google\.com' or grep -Fq google.com, but better here would be to use a case statement and drop grep altogether: case $mailServ in (*google.com*) printf '%s uses google for mail\n' "$mailServ" esac -- Stephane