Code:
$ cat ./testgrep.ksh
#!/bin/ksh
WORD=abc12345
echo $WORD|grep -qE "[[:digit:]]{5}$"
if [ $? -eq 0 ]; then
echo "Do this with $WORD"
else
echo "Else do this with $WORD"
fi
WORD2=ab123456
echo $WORD2|grep -qE "[[:digit:]]{5}$"
if [ $? -eq 0 ]; then
echo "Do this with $WORD2"
else
echo "Else do this with $WORD2"
fi
WORD3=abc1234
echo $WORD3|grep -qE "[[:digit:]]{5}$"
if [ $? -eq 0 ]; then
echo "Do this with $WORD3"
else
echo "Else do this with $WORD3"
fi
exit 0
$ ./testgrep.ksh
Do this with abc12345
Do this with ab123456
Else do this with abc1234