On Tue, May 01, 2001 at 10:43:40PM -0700, Jeremy C. Reed wrote: > Does anyone know of a grep that can use multiple expressions that some > are reversed, for example, one grep that can do the same as "grep > keyword | grep -v exclude" (without knowing the placement of the > keywords in the line)? > > Or can anyone share some examples of using awk to do this?
use perl. for example: ---cut here--- #! /usr/bin/perl # arguments: # -i include regexp # -e exclude regexp # remaining args are file(s) to search use Getopt::Std ; getopt('i:e:',\%opts); # unbuffer output $|=1; while (<>) { next unless (/$opts{"i"}/io); next if (/$opts{"e"}/io) ; print ; } ---cut here--- the -i and -e arguments are regular expressions, not just literal strings so you can make them as simple or as complex as you like. craig -- craig sanders <[EMAIL PROTECTED]> GnuPG Key: 1024D/CD5626F0 Key fingerprint: 9674 7EE2 4AC6 F5EF 3C57 52C3 EC32 6810 CD56 26F0