[comp.unix.questions] how to grep multiply strings

pat@ctycal.UUCP (Patrick Woo) (02/01/91)

I am trying to display line that doesn't contain string1 or string2 or ...
stringn.

What I did was

grep -v string1 | grep -v string2 | .... | grep -v stringn

Just wondering if there is an easier way other than doing all this piping.
Thanks in advance.

-- 
  Patrick Woo                  pat%ctycal@cpsc.ucalgary.ca
  Land Information Services                 or
  The City of Calgary       ...{alberta,ubc-cs,uunet}!calgary!ctycal!pat

tchrist@convex.COM (Tom Christiansen) (02/02/91)

From the keyboard of pat@ctycal.UUCP (Patrick Woo):
:I am trying to display line that doesn't contain string1 or string2 or ...
:stringn.

:What I did was
:
:grep -v string1 | grep -v string2 | .... | grep -v stringn
:
:Just wondering if there is an easier way other than doing all this piping.
:Thanks in advance.

    egrep -v 'string1|string2|string3|...|stringN' file

or put them in a file and use 

    fgrep -vf badstrings file

Bear in mind that most standard fgrep's are terribly slow.

--tom
--
"Hey, did you hear Stallman has replaced /vmunix with /vmunix.el?  Now
 he can finally have the whole O/S built-in to his editor like he
 always wanted!" --me (Tom Christiansen <tchrist@convex.com>)

pat@ctycal.UUCP (Patrick Woo) (02/05/91)

In article <531@ctycal.UUCP>, pat@ctycal.UUCP (Patrick Woo) writes:
> I am trying to display line that doesn't contain string1 or string2 or ...
> stringn.
> 
> grep -v string1 | grep -v string2 | .... | grep -v stringn
> Just wondering if there is an easier way other than doing all this piping.

Thanks for all the replies, here is the summary

egrep -v 'string1|string2| ... | stringN'
sed -e '/string1/d' -e 'string2/d' ... -e '/stringN/d'
-- 
  Patrick Woo                  pat%ctycal@cpsc.ucalgary.ca
  Land Information Services                 or
  The City of Calgary       ...{alberta,ubc-cs,uunet}!calgary!ctycal!pat

luj@gus17.ecn.purdue.edu (Jun Lu) (02/28/91)

In article <531@ctycal.UUCP> pat@ctycal.UUCP (Patrick Woo) writes:
>I am trying to display line that doesn't contain string1 or string2 or ...
>stringn.
>
>What I did was
>
>grep -v string1 | grep -v string2 | .... | grep -v stringn
>
>Just wondering if there is an easier way other than doing all this piping.
>Thanks in advance.
>

How about 
	egrep -v 'string1|string1|...|stringn' 
?

--
-- Jun Lu                          Internet:luj@ecn.purdue.edu          --
-- Aeronautics & Astronautics      Bitnet:  luj%ecn.purdue.edu@purccvm  --
-- Purdue University               UUCP:    pur-ee!luj                  -- 
-- W. Lafayette, IN 47907          Phone:317-494-9410  Fax:317-494-0307 --