LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   matching not working as expected... (https://www.linuxquestions.org/questions/programming-9/matching-not-working-as-expected-890009/)

sebelk 07-05-2011 07:14 AM

matching not working as expected...
 
Hi,

I have the file /tmp/qqq that contains:

Code:

2
5
232323
A

If I issue:

Code:

sed  /[0-9]\{3\}/p  /tmp/qqq
It prints all lines

I don't know why because if I run:

Code:

egrep [0-9]{3} /tmp/qqq
It outputs only:

Code:

232323

I tried even with and without quoting or even with and with without "\" or even using "-r". OK in this little example I could use egrep but I am trying to do something more complex and sed would be useful if it worked as I (perhaps wrong) expected

Could you help me?

druuna 07-05-2011 07:17 AM

Hi,

Code:

sed -n '/[0-9]\{3\}/p' /tmp/qqq
Hope this helps.


All times are GMT -5. The time now is 11:25 PM.