Hallo,
Ich möchte eine Variable untersuchen, ob eine bestimmte Zeichenfolge drin vorkommt.
Mir fällt im Moment nur folgendes Konstrukt ein:
test=`echo $string | grep $such`
if [ "$test" != "" ]
then
.....
fi
hat jemand ne bessere Idee?
MfG
jsffm
Hallo,
Ich möchte eine Variable untersuchen, ob eine bestimmte Zeichenfolge drin vorkommt.
Mir fällt im Moment nur folgendes Konstrukt ein:
test=`echo $string | grep $such`
if [ "$test" != "" ]
then
.....
fi
hat jemand ne bessere Idee?
MfG
jsffm
ungetested:
if [ $(echo $string | grep $such) ] ; then
...
fi
ansonsten schau dir auch mal sed an ...
schön geht das mit case:
case $INPUTSTRING in
*substring*)
echo "heureka"
;;
esac
mfg
Don’t have an account yet? Register yourself now and be a part of our community!