Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string=`echo My string`
- if [ $string ?? 'foo' ] then;
- echo "It's there!";
- fi;
- if [ `echo $string || grep 'foo' ` ] then;
- echo "It's there!";
- fi;
- string='My string';
- if [[ $string == *My* ]]
- then
- echo "It's there!";
- fi
- case "$string" in
- *foo*)
- # Do stuff
- ;;
- esac
- string='My string';
- if [[ $string =~ .*My.* ]]
- then
- echo "It's there!"
- fi
- if [ "$string" != "${string/foo/}" ]; then
- echo "It's there!"
- fi
- if grep -q foo <<<$string; then
- echo "It's there"
- fi
- text=" <tag>bmnmn</tag> "
- if [[ "$text" =~ "<tag>" ]]; then
- echo "matched"
- else
- echo "not matched"
- fi
- str=this_is_my_string
- if [ `expr match "$str" ".*my.*"` != "0" ]; then
- echo "there";
- fi;
- expr "$variable" : 'regex'
- if [ "$string" != "${string/foo/}" ]; then echo "It's there!" fi
- [ $(expr $mystring : ".*${search}.*") -ne 0 ] && echo 'yes' || echo 'no'
- [ $(expr $mystring : ".*${search}.*") -ne 0 ] && echo 'yes' || echo 'no'
Add Comment
Please, Sign In to add comment