文字列に別の文字列が含まれているか調べる(expr)

sedgrepと異なり正規表現との比較は文字列の先頭からのみ行われる
(正規表現の先頭に^が追加されていると考える)
文字列"hello world"に対して正規表現"hello"".*world"はマッチするが
"world"はマッチしない

#!/bin/sh
#str_find_expr.sh

text="The quick brown fox jumps over the lazy dog."
if expr "$text" : '.*fox' >/dev/null; then
    echo "fox was found."
else
    echo "not found."
fi
$ ./str_find_expr.sh 
fox was found.