bugfindutils - Bugs: bug #33459, Find -exec not working correctly...


bug #33459: Find -exec not working correctly with binary matching

Submitted by:  None
Submitted on:  Wed 01 Jun 2011 11:21:05 PM UTC  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Works For Me
Privacy: PublicAssigned to: Eric Blake <ericb>
Originator Name: Bjorn d.Originator Email: -unavailable-
Open/Closed: ClosedRelease: 4.4.2
Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Thu 02 Jun 2011 12:38:44 AM UTC, comment #3:

Thanks for the quick reply. I didn't understand that actions are only done on the preceding expression excluding -print. However -prune is only one the preceding expression while expressions still print if you don't have another action in one of them.

works just as well as:

I also now see where this is addressed in the man file. Thank you for your time.

Thu 02 Jun 2011 12:01:33 AM UTC, comment #2:

are identical to:


is identical to:

Notice that the absence of -print or -exec results in implicit () around the rest of the expressions.

but the first 2 commands give the following output
the last command outputs properly with

In all three commands, the results you saw are correct. I think the only bug here is that you misunderstood how the implicit -print also implies (), which changes precedence on the rest of the line.

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Wed 01 Jun 2011 11:35:29 PM UTC, comment #1:
Wed 01 Jun 2011 11:21:05 PM UTC, original submission:

find . -name test1 -or -name test2 -exec echo {} \;
find . -name test1 -or -name test2 -print
should produce output equal to
find . -name test1 -or -name test2
but the first 2 commands give the following output
the last command outputs properly with

find -name "test" -a -name "[1-2]" -print
produces correct output but
find -name "test" -a -name "[1-2]" -exec echo {} \;
produces an extra /n before giving the correct output which just
find -name "test[1-2]" --exec echo {} \;
doesn't produce. Maybe a separate bug.

I am using Ubuntu and "find --version" gives the following
find (GNU findutils) 4.4.2
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0)

Bash Code to reproduce, it should produce the same output for all the find commands without an blanklines:

touch test1 test2
find . -name test1 -or -name test2 -exec echo {} \;
find . -name test1 -or -name test2 -print
find -name "test" -a -name "[1-2]" -exec echo {} \;
find . -name test1 -or -name test2



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jay (Updated the item)
  • -unavailable- added by ericb (Posted a comment)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 12 Jul 2014 12:48:28 PM UTCjayStatusNone=>Works For Me
      Assigned toNone=>ericb

    Back to the top

    Powered by Savane 3.1-cleanup