With all
Bourne-type shells* you can use
case and
wildcards pattern matching (*I believe the
csh family uses a different syntax):
Code:
a="string with piece to search"
case $a in
*piece*) printf "OK\n";;
*) printf "KO\n";;
esac
With
ksh93,
zsh and
bash:
Code:
[[ $a == *piece* ]]&&printf "OK\n"||printf "KO\n"
With some versions of the above shells you can even match using
regular expressions with the
=~ operator.