Joe Smith wrote:
> 
> Pierre Fortin wrote:
> ...
> > I would think this indicates that "find" is buggy since the "-o|-or|," does not
> > seem to work as documented...  comments...?
> ...
> 
> find(1) is a first-class bitch of a program.  It consistently trips me
> up with it's arcane syntax and unexpected behavior.

AMEN! on the trip-ups; but I still think find is buggy...  more below...

> In this case, you are being bitten by the fact that find follows the
> file globbing behavior of the shell (from 'info find'):
>       In the `find' tests that do shell pattern matching (`-name',
>    `-path', etc.), wildcards in the pattern do not match a `.' at the
>    beginning of a file name.

IOW, "find ." sees *all* the files, then the matching part sucks.

> Your problem with '-or' is that there is an implied '-and' before
> '-print', so that you are really doing 'a or b and c', which is
> different than 'b or a and c' because 'and' has higher precedence.  If
> you use parens (or drop the '-print'), it works as you expect:

>From man:
 -print True; print the full file name on the standard output, followed by a
newline.
        ^^^^
so:  'a or b and 1' is the same as 'a or b' since the result of 'b and 1' will
always be 'b'
Ditto for 'b or a and 1'
Hence, '-print' should not be a factor in the output; yet *each* of the
following commands:

$ find .test -print -iname test\* -iname .test\*  # (implied -and)
             ^^^^^^
$ find .test -iname test\* -or -iname .test\*
                           ^^^
give: 

.test
.test/test1
.test/test1/test2
.test/test1/test2/TEST2
.test/test1/TEST1
.test/.test1
.test/.test1/.test2
.test/.test1/.test2/.TEST2
.test/.test1/.TEST1

Where's the logic in that..?  :^)

Yet:

$ find .test -iname test\* -iname .test\*
$ find .test -iname test\* -or -iname .test\* -or -print

give no output!  Implies that '-print', while "True", impacts the results of the
tests by causing alteration of the remaining parm relationships...  I think this
is more than arcane, it's plain buggy, IMHO...
                                                                                       
                          
Interesting, no...?  :^)

Pierre

> $ find . \( -iname '.test*' -o -iname 'test*' \) -print
> ./.test
> ./.test/test1
> ./.test/test1/test2
> ./.test/test1/test2/TEST2
> ./.test/test1/TEST1
> ./.test/.test1
> ./.test/.test1/.test2
> ./.test/.test1/.test2/.TEST2
> ./.test/.test1/.TEST1
> 
> As far as the original problem, I would suggest keeping the find part as
> simple as possible and use grep to do the matching:
> 
> $ find . -type f | grep test
> 
> Or, more precisely:
> 
> $ find . -type f | grep 'read[^/]*$'
> 
> to limit the match to the filename component.
> 
> <Joe

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to