Why does not work first and second variants, but third works
#!/bin/sh
#---------------------------------------------
text="my:?text=this:one"
if (echo $text | grep '^my\:\?text=this\:one') then
echo "1"
elif (echo $text | grep '^my:\?text=this:one') then
echo "2"
elif (echo $text | grep 'text=this:one') then
echo "3"
fi
grep does not use regular expressions by default, add the
-Eflag to enable extended regular expressions.Edit: grep does not use extended regular expressions by default, and
grep -Eis usually aliased toegrepfor quicker use