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.

From: Martin on
no.top.post(a)gmail.com wrote:

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

That would be grep, too, but at the expense of bad time complexity. If the
number of lines is large I'd write a small perl script for that or -- better
still -- for the -exec.

Martin

From: Helmut Hullen on
Hallo, no.top.post,

Du meintest am 08.08.10:

> 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 {}

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

"that depends!" - I don't know what you want to see. If you only want
"dog" but not "dogFile" then please add the option "-w".

Viele Gruesse
Helmut

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

From: Grant on
On Sun, 8 Aug 2010 03:03:34 +0000 (UTC), no.top.post(a)gmail.com wrote:

>*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> ??

If you want lines that contain all the names just run grep in series
to AND them, rather than the examples above which OR them.

So is it find ... fish | grep dog | grep kat you're after?

Filters in sequence, no intermediate files.

Otherwise, express your homework a bit better ;)

Grant.
From: William Hunt on
On Sun, 8 Aug 2010, Grant wrote:
> On Sun, 8 Aug 2010 03:03:34 +0000 (UTC), no.top.post(a)gmail.com wrote:
>
[...]
> >and then what's the utility to:
> ><list the common lines of: fishFile, dogFile, katFile> ??
>
> If you want lines that contain all the names just run grep in series
> to AND them, rather than the examples above which OR them.
>
> So is it find ... fish | grep dog | grep kat you're after?
> Filters in sequence, no intermediate files.
>
> Otherwise, express your homework a bit better ;)
> Grant.


(sigh)

find ... | awk '/dog/&&/cat/&&/fish/'

:*)

--
William Hunt, Portland Oregon USA
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Thunderbird 3
Next: Checking state of inserted DVD media?