find buglet

bridged with qnx.development_tools
Post Reply
Bill Caroselli

find buglet

Post by Bill Caroselli » Tue May 04, 2004 1:48 pm

I think I found a bug in find
(i.e. I don't think I'm just using it wrong).

If I type:
find . -name \*~ -o -name \*.o -print
it only find *.o files.

If I type:
find . -name \*.o -o -name \*~ -print
then it only finds *~ files.

I.E. it is ignoring files found before the OR.

If my syntax is wrong, could someone please correct me.
If my syntax is not wrong, then find has a bug.

I'm running 6.2.1B PE.

Steve Reid

Re: find buglet

Post by Steve Reid » Tue May 04, 2004 2:09 pm

Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
Bill Caroselli wrote:
I think I found a bug in find
(i.e. I don't think I'm just using it wrong).

If I type:
find . -name \*~ -o -name \*.o -print
it only find *.o files.

...

I think the problem is that implicit "and" before the -print has a
precedence over the "or", i.e. your syntax is equivalent to

find . \( -name \*~ \) -o \( -name \*.o -a -print \)
I see that the docs mention the implicit -a operand, but it's a subtle
point. I'll add this example to the docs.

------------------------------------------
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems
------------------------------------------

Colin Burgess

Re: find buglet

Post by Colin Burgess » Tue May 04, 2004 2:26 pm

wrong syntax

you need

find . -name \*~ -print -o -name \*.o -print

Bill Caroselli wrote:
I think I found a bug in find
(i.e. I don't think I'm just using it wrong).

If I type:
find . -name \*~ -o -name \*.o -print
it only find *.o files.

If I type:
find . -name \*.o -o -name \*~ -print
then it only finds *~ files.

I.E. it is ignoring files found before the OR.

If my syntax is wrong, could someone please correct me.
If my syntax is not wrong, then find has a bug.

I'm running 6.2.1B PE.
--
cburgess@qnx.com

Wojtek Lerch

Re: find buglet

Post by Wojtek Lerch » Tue May 04, 2004 2:32 pm

Bill Caroselli wrote:
I think I found a bug in find
(i.e. I don't think I'm just using it wrong).

If I type:
find . -name \*~ -o -name \*.o -print
it only find *.o files.
....

I think the problem is that implicit "and" before the -print has a
precedence over the "or", i.e. your syntax is equivalent to

find . \( -name \*~ \) -o \( -name \*.o -a -print \)

Bill Caroselli

Re: find buglet

Post by Bill Caroselli » Tue May 04, 2004 5:29 pm

Colin Burgess <cburgess@qnx.com> wrote:
CB > wrong syntax

CB > you need

CB > find . -name \*~ -print -o -name \*.o -print

What I've settled on is:
find . \( -name \*~ -o -name \*.o \) -print

My -print command is actually -remove! but I also use this find
syntax to -exec other commands.

Post Reply

Return to “qnx.development_tools”