[lug] grep question

Tkil tkil at scrye.com
Tue Jan 29 12:56:26 MST 2002


>>>>> "Scott" == Scott A Herod <herod at interact-tv.com> writes:

Scott> I need a grep command that returns true if either or both is
Scott> present.  The grep man page suggests that you can use the infix
Scott> operator | (the pipe symbol) but I can't figure out the syntax.
Scott> Does anyone know how?

try "egrep"; i don't recall if plain grep can do alternation.

| if egrep -q 'foo|bar' $file > /dev/null 2>&1
| then
|     echo "found foo or bar"
| fi

note the "-q", a possible optimization.

t.



More information about the LUG mailing list