Re: grep AND regular expression
From: Barry Margolin (barry.margolin_at_level3.com)
Date: 11/07/03
- Previous message: Vinod Gupta: "grep AND regular expression"
- In reply to: Vinod Gupta: "grep AND regular expression"
- Next in thread: Vinod Gupta: "Re: grep AND regular expression"
- Reply: Vinod Gupta: "Re: grep AND regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 07 Nov 2003 16:28:20 GMT
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). The more general
way to solve it is with piping:
grep 'str1' | grep 'str2' | grep 'str3' ...
-- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
- Previous message: Vinod Gupta: "grep AND regular expression"
- In reply to: Vinod Gupta: "grep AND regular expression"
- Next in thread: Vinod Gupta: "Re: grep AND regular expression"
- Reply: Vinod Gupta: "Re: grep AND regular expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]