Newsgroups: comp.unix.shell
> What's the best way to find out if a string has a certain letter in it? > So when i assign var=ABCD i would like to check if this var has a > letter B in it. How to do it ? (i can only think of a messy loop)
bourne shell :
case $var in *B*) echo found ;; *) echo not found ;; esac
korn shell (same as the bourne shell + ) :
if [[ $var = *B* ]]; then echo found else echo not found fi
Cyrille.
documented on: 2000.08.28 Mon 21:44:34