LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   regular expression not working. grep[^0-9] (https://www.linuxquestions.org/questions/linux-general-1/regular-expression-not-working-grep%5B%5E0-9%5D-4175527185/)

lm_suresh 12-03-2014 06:26 AM

regular expression not working. grep[^0-9]
 
echo 8989898989898 |grep [^0-9] > /dev/null 2>&1
if [ "$?" -eq "0" ]
then
echo "inside if "
nrec=1
fi


output shows..

+ echo 8989898989898
+ grep 3
+ 1> /dev/null 2>& 1
+ [ 1 -eq 0 ]

Not sure how grep [^0-9] is converted to 3 . Any help.

smallpond 12-03-2014 06:28 AM

You need to put the expression in quotes. It is being interpreted by the shell.

pan64 12-03-2014 07:08 AM

you can check it by:
echo [^0-9]


All times are GMT -5. The time now is 05:26 AM.