19Jan 2005 Finding the contents of a variable within a string by troyski ⋅ Leave a Comment Sounds hard, but quite easy… var=”pattern to find” string=”Full string where the pattern to find is.” echo “$string” | grep “$var” rc=$? if [[ $rc = 0 ]];then echo “I found $var in $string” fi