set exist_substring = `echo $string | grep -c $substring`
if ( $exist_substring == 1 ) then
echo "$substring exists in the $string"
endif
2) ---to test if str exists in $mystring:
echo $mystring | awk '{print index($0, "str")}'" searches the $mystring variable for an occurrence of "str" in the string's value.
if exists, return 1, otherwise 0
echo $mystring | awk '{print index($0, "str")}'" searches the $mystring variable for an occurrence of "str" in the string's value.
if exists, return 1, otherwise 0
Aucun commentaire:
Enregistrer un commentaire