Re: grep AND regular expression
From: Vinod Gupta (vkgupta_at_princeton.edu)
Date: 11/07/03
- Next message: Lowell: "Re: Uncrypt a file"
- Previous message: Jose Luis Fern?ndez D?az: "Uncrypt a file"
- In reply to: Barry Margolin: "Re: grep AND regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 7 Nov 2003 14:27:18 -0800
Barry Margolin <barry.margolin@level3.com> wrote in message news:<EKPqb.408$lK3.380@news.level3.com>...
> In article <17581f0c.0311070822.3b5fa7a1@posting.google.com>,
> Vinod Gupta <vkgupta@princeton.edu> wrote:
> >While one could search for str1 OR str2 by egrep "str1|str2",
> >what would be the regular expression to search for str1 AND str2?
>
> For very simple cases you can do:
>
> grep -E 'str1.*str2|str2.*str1'
>
> but this doesn't generalize very well because of combinatorial explosion
> (and it also fails completely if str1 and str2 overlap).
You are very right
>The more general way to solve it is with piping:
>
> grep 'str1' | grep 'str2' | grep 'str3' ...
Better, but this won't let us use full power of grep that we want to
apply
on records matching the ANDed expression, for instance, what if I want
to exclude the records matching the expression (-v)?
Vinod.
- Next message: Lowell: "Re: Uncrypt a file"
- Previous message: Jose Luis Fern?ndez D?az: "Uncrypt a file"
- In reply to: Barry Margolin: "Re: grep AND regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|