Re: Quick grep question
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 27 Feb 2006 18:39:05 GMT
On Mon, 27 Feb 2006 13:17:19 -0500, Chris F.A. Johnson wrote:
On 2006-02-27, Samik R wrote:[...]
Hello,
I am trying to match couple of lines using grep. Assuming my file
has following 3 lines:
inx23r678
inx34r54
inx23_44
I want the lines with inx<some digits>r<some digits>, not the
underscore ones. I am trying this:
cat file|grep "inx[0-9]+r"
which is not working. But,
cat file|grep "inx[0-9]*r"
is working. I thought '+' matches with 1 or more occurrences, so the
first one should work too. Where am I going wrong?
First, you don't need cat; second, you need to escape the plus
sign:
grep "inx[0-9]\+r" file
Neither + nor \+ are BRE operators, so are not supposed to work
with grep. Some grep implementations such as GNU grep recognise
\+ as an extension.
What is standard BRE is \{1,\} (one or more occurrences of the
previous pattern).
+ is a standard ERE operator, -E is a standard option to grep to
understand a pattern as an ERE.
--
Stephane
.
- References:
- Quick grep question
- From: Samik R
- Re: Quick grep question
- From: Chris F.A. Johnson
- Quick grep question
- Prev by Date: Re: Quick grep question
- Next by Date: Re: Preserving newlines and carriage returns...
- Previous by thread: Re: Quick grep question
- Next by thread: Re: Quick grep question
- Index(es):
Relevant Pages
|
|