Thursday, January 22, 2009

Regular Expression in if in bash script

if echo "4567" | grep -q "^4"; then
echo "4567 is started with a 4."
elif echo "4567" | grep -q "^A"; then
echo "4567 is started with a A."
else
echo "4567 is NOT started with a 4 or A."
fi

No comments: