LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-03-2014, 06:26 AM   #1
lm_suresh
LQ Newbie
 
Registered: Dec 2014
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 12-03-2014, 06:28 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,123

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
You need to put the expression in quotes. It is being interpreted by the shell.
 
Old 12-03-2014, 07:08 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,630

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to use regular expression in grep? sagarkha Linux - Newbie 6 01-23-2010 08:15 AM
grep regular expression casperdaghost Linux - Newbie 2 08-15-2009 11:01 AM
grep Regular Expression lamar_air Programming 2 07-24-2006 03:40 PM
Help with grep regular expression lamar_air Programming 3 07-21-2006 11:26 AM
Regular Expression + not Working with grep scottwmackey Linux - General 2 06-21-2006 01:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration