From: Peter Chant on
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"

Hmm, since 'cat' and 'fish' are available commands on my slack install at
least, I see chance for great confusion...



--
http://www.petezilla.co.uk
From: Aragorn on
On Tuesday 27 July 2010 23:20 in comp.os.linux.misc, somebody
identifying as Peter Chant wrote...

> 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"
>
> Hmm, since 'cat' and 'fish' are available commands on my slack install
> at least, I see chance for great confusion...

"dog" is also a command - it's an improved version of "cat", similar to
how "less"[*] is an improved version of "more" - albeit that it's not
installed by default on most systems. ;-)

[*] There's also an improved version of "less" *and* "more",
called "most". :p Gotta love those GNU hackers. ;-)

--
*Aragorn*
(registered GNU/Linux user #223157)
From: Peter Chant on
Aragorn wrote:


> "dog" is also a command - it's an improved version of "cat", similar to
> how "less"[*] is an improved version of "more" - albeit that it's not
> installed by default on most systems. ;-)
>
> [*] There's also an improved version of "less" *and* "more",
> called "most". :p Gotta love those GNU hackers. ;-)
>

Time to renew my C skills - "mostly" an advanced version of "some". (skips
every 5th line on average) :-)

I'll leave it to the newsgroup to debate "less" versus "fewer"...

--
http://www.petezilla.co.uk
From: William Hunt on
On Wed, 28 Jul 2010, Aragorn wrote:
> On Tuesday 27 July 2010 23:20 in comp.os.linux.misc, somebody
> identifying as Peter Chant wrote...
>> no.top.post(a)gmail.com wrote:
[...]
>>> Now I want command/s to find files containing MULTIPLE strings like:
>>> "dog", "cat", "fish"
>>
>> Hmm, since 'cat' and 'fish' are available commands on my slack install
>> at least, I see chance for great confusion...
>
> "dog" is also a command - it's an improved version of "cat", similar to
> how "less"[*] is an improved version of "more" - albeit that it's not
> installed by default on most systems. ;-)

for years i've been using a sleazy local script, dog,
to strips '#' comments out of text data files:

$ cd /usr/local/bin
$ cat dog
#!/usr/bin/sed -f
/^[ ]*#/d
/^[ ]*$/d
s/[ ][ ]*#.*//
$ dog dog
/^[ ]*#/d
/^[ ]*$/d
s/[ ][ ]*#.*//
$

--
William Hunt, Portland Oregon USA
From: no.top.post on
*MULTIPLE* strings are not *alternative* strings.
Perhaps you need to think beyond just using ready made
utilities?

Various contibutors guessed at:
1> egrep -l "dog\|cat\|fish" {}
2> find . -exec egrep -l "\(dog\|cat\|fish\)" {} \;
3> grep -l -e dog -e cat -e fish *
4> find . -exec egrep -l "(dog|cat|fish)" {}
4> find . -exec grep -l "\(dog\|cat\|fish\)" {}
4> find . -exec grep -l -e dog -e cat -e fish {}

AFAIK grep looks at 1 line at a time.
The algorithm [which I've done in ETH-oberon]
needs to:
FOR QualifingFile DO
CHECK for EACH/ALL strings.

You might want to check whole file, for each string,
and exit with failure when if is not found. Else print
the FileID as containg all strings.

The method chosen might depend on how the
existing *nix helper-utilities work.
---
A somewhat 'lame' solution is to use the proven
one liner to fine 'new' files containing string 'fish':
find ./ -ctime -22 -exec grep -l "fish" {} \; >> fishFile
and
find ./ -ctime -22 -exec grep -l "dog" {} \; >> dogFile
find ./ -ctime -22 -exec grep -l "kat" {} \; >> katFile

and then what's the utility to:
<list the common lines of: fishFile, dogFile, katFile> ??

== TIA.