-   Linux - General (
-   -   Regular Expression + not Working with grep (

scottwmackey 06-20-2006 09:21 PM

Regular Expression + not Working with grep
Does anybody know why the last grep doesn't return anything?


[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

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

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

[smackey@copper ~]$

pixellany 06-20-2006 11:43 PM

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

scottwmackey 06-21-2006 02:31 AM

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.


All times are GMT -5. The time now is 12:17 PM.