From: no.top.post on
Someone kindly provided the following very useful one-liner
to find all <recent> files containing 'a string':-

find ./ -ctime -2 -exec grep -l "a string" {} \;

Now I want command/s to find files containing MULTIPLE strings like:
"dog", "cat", "fish"

== TIA

From: root on
no.top.post(a)gmail.com <no.top.post(a)gmail.com> wrote:
> Someone kindly provided the following very useful one-liner
> to find all <recent> files containing 'a string':-
>
> find ./ -ctime -2 -exec grep -l "a string" {} \;
>
> Now I want command/s to find files containing MULTIPLE strings like:
> "dog", "cat", "fish"
>
>== TIA
>

Use egrep:
egrep -l "dog\|cat\|fish" {}
From: Helmut Hullen on
Hallo, root,

Du meintest am 27.07.10:

>> Someone kindly provided the following very useful one-liner
>> to find all <recent> files containing 'a string':-
>>
>> 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, but

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

doesn't work.

Viele Gruesse
Helmut

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

From: Joost Kremers on
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\)"


--
Joost Kremers joostkremers(a)yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
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