If not too many matching lines, store them in a variable!
special=`grep somestring somefile`
if [ -n "$special" ]
then
echo "$special" | mail ...
fi
---------- Post updated at 12:58 PM ---------- Previous update was at 12:35 PM ----------
Just seeing this is in principal the same as the previous answer.
No, the shell does not clutch anything together.
An echo $var does a reformatting, but not an echo "$var"
Outch, sorry Makarand, I missed that small difference the double quotes make around the variable.
Thanks (from Germany), also to "Made in Germany" for pointing that out.
Makarand's solution can even be abbreviated, as grep gives returncode 0 if it was successful (and 1 if not):