LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 06-20-2006, 08:21 PM   #1
scottwmackey
LQ Newbie
 
Registered: Jun 2006
Posts: 2

Rep: Reputation: 0
Regular Expression + not Working with grep


Does anybody know why the last grep doesn't return anything?

Code:
[smackey@copper ~]$ uname -a
Linux <deleted> 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux

[smackey@copper ~]$ cat my_test.txt
abcdefg

[smackey@copper ~]$ grep 'a.*e' my_test.txt
abcdefg

[smackey@copper ~]$ grep 'a.+e' my_test.txt

[smackey@copper ~]$
 
Old 06-20-2006, 10:43 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
in bash, the "+" is not recognized as a special character unless you specify extended regular expressions by using "grep -E" or "egrep"

Bash Guide for Beginners, Machtelet Garrels .....avail. at tldp.org
 
Old 06-21-2006, 01:31 AM   #3
scottwmackey
LQ Newbie
 
Registered: Jun 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks much. egrep works like a charm. But now I feel like a complete idiot. I was looking at the man pages for grep, saw the egrep variant right there at the top, but I must have figured it was far too much work to try the command. Hell, it might not have worked and I would have wasted a whole key stroke. Much easier to search the web for an hour and then post to a forum. Thanks again.

Scott
 
  


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
problems with regular expression and grep bwreath Linux - General 6 03-18-2005 01:43 PM
Need help with Regular Expression subaruwrx Linux - Newbie 6 09-04-2004 07:48 PM
grep usage with regular expression jonathanztaub Linux - General 7 09-01-2004 10:35 PM
Regular Expression Help WeNdeL Linux - General 1 08-14-2003 10:08 AM
regular expression gumby Programming 3 07-15-2003 12:13 PM


All times are GMT -5. The time now is 09:05 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration