bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Grep: --quiet & suggestion


From: Jori Mantysalo
Subject: Grep: --quiet & suggestion
Date: Sun, 8 Jun 2003 12:02:58 +0300 (EEST)

Is this one a bug or feature?

$ cat text
cat
dog
$ (grep -q -m 1 cat ; grep -q -m 1 dog) < text && echo 'Found!'
$ (grep -m 1 cat ; grep -m 1 dog) < text && echo 'Found!'
cat
dog
Found!

An question: is there easy way to find text files containing first "cat"
and then later "dog"? If you say
 (grep -m 1 cat ; grep -m 1 dog) > /dev/null < text && echo 'Found!'
it will work if text is cat-linefeed-dog, but it doesn't work if text is
cat-space-dog. Somehow I think that grep should have option like -m which
would work with -o and ensures that standard input is positioned to just
after the last match, not after last matching line.

-- 
Jori Mäntysalo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]