From: Clemens Ladisch on
Helmut Hullen wrote:
>>> find ./ -ctime -2 -exec grep -l "a string" {} \;
>>>
>>> Now I want command/s to find files containing MULTIPLE strings like:
>>> "dog", "cat", "fish"
>
>> Use egrep:
>> egrep -l "dog\|cat\|fish" {}
>
> Sorry - doesn't work here.
>
> egrep -l "\(dog\|cat\|fish\)" *
>
> works

This doesn't work here, this should be either
egrep -l "(dog|cat|fish)" *
or
grep -l "\(dog\|cat\|fish\)" *
or just tell grep to use multiple patterns:
grep -l -e dog -e cat -e fish *

> find . -exec egrep -l "\(dog\|cat\|fish\)" {} \;
>
> doesn't work.

Any of these work:

find . -exec egrep -l "(dog|cat|fish)" {} +
find . -exec grep -l "\(dog\|cat\|fish\)" {} +
find . -exec grep -l -e dog -e cat -e fish {} +


Regards,
Clemens
From: Helmut Hullen on
Hallo, Joost,

Du meintest am 27.07.10:

>> find . -exec egrep -l "\(dog\|cat\|fish\)" {} \;
>>
>> doesn't work.

> try

> find . -ctime -2 | xargs egrep -l "\(dog\|cat\|fish\)"

Dankesch�n - kommt ins Archiv.

Viele Gruesse
Helmut

"Ubuntu" - an African word, meaning "Slackware is too hard for me".

From: Helmut Hullen on
Hallo, Clemens,

Du meintest am 27.07.10:

>> find . -exec egrep -l "\(dog\|cat\|fish\)" {} \;
>>
>> doesn't work.

> Any of these work:

> find . -exec egrep -l "(dog|cat|fish)" {} +
> find . -exec grep -l "\(dog\|cat\|fish\)" {} +
> find . -exec grep -l -e dog -e cat -e fish {} +

Many thanks too - especially for the example with multiple "-e".

And I shouldn't mix "egrep" and "grep -e" ...

Viele Gruesse
Helmut

"Ubuntu" - an African word, meaning "Slackware is too hard for me".

From: Eef Hartman on
In alt.os.linux.slackware Helmut Hullen <Helmut(a)hullen.de> wrote:
> And I shouldn't mix "egrep" and "grep -e" ...

egrep is essentially grep -E. It can handle everything "normal" grep
can, but has "extended" regular expressions, which means the "patterns
to search for" can be more complicated/powerful.
So: -E extended re's
-e expression (regular expression or simple text string)
those options shouldn't be confused, but CAN be combined in one
commandline (and you can have multiple -e's).
--
******************************************************************
** Eef Hartman, Delft University of Technology, dept. SSC/ICT **
** e-mail: E.J.M.Hartman(a)tudelft.nl - phone: +31-15-27 82525 **
******************************************************************
From: Balwinder S Dheeman on
On 07/27/10 13:23, Joost Kremers wrote:
> Helmut Hullen wrote:
>> Sorry - doesn't work here.
>>
>> egrep -l "\(dog\|cat\|fish\)" *
>>
>> works, but
>>
>> find . -exec egrep -l "\(dog\|cat\|fish\)" {} \;
>>
>> doesn't work.
>
> try
>
> find . -ctime -2 | xargs egrep -l "\(dog\|cat\|fish\)"

I have not tested, but am curious why not:

find . ... -O<level> -regextype -regex

man find # for further details

--
Balwinder S "bdheeman" Dheeman Registered Linux User: #229709
Anu'z Linux(a)HOME (Unix Shoppe) Machines: #168573, 170593, 259192
Chandigarh, UT, 160062, India Plan9, T2, Arch/Debian/FreeBSD/XP
Home: http://werc.homelinux.net/ Visit: http://counter.li.org/