Re: RegEx: find words in random order

"Cameron Simpson [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 08Apr2015 15:40, Jim Schneider <[email protected]> wrote:
>For straight unix, you can use
>grep color input.txt | grep -e red -e blue

Indeed.

Also, I have a script called "grepall" which looks for lines with multiple 
regexps:

  grepall regex1 regex2 regex3... < input.txt

It is here (use the "Raw" link to get the bare file content):

  https://bitbucket.org/cameron_simpson/css/src/tip/bin/grepall

It work by constructing a sed script that looks like this:

  /regexp1/!d
  /regexp2/!d
  /regexp3/!d

as needed i.e. discard lines lacking any of the regexps. You could easily adapt 
that approach instead of nesting regexps as in Tim's example.

Just an alternative approach.

Cheers,
Cameron Simpson <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.