bugfindutils - Bugs: bug #50780, -type option after printf is...


bug #50780: -type option after printf is ignored

Submitted by:  yan <yanpas>
Submitted on:  Mon 10 Apr 2017 05:18:08 PM UTC  
Category:  find Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  4.6.0 Fixed Release:  None

Add a New Comment (Rich Markup)

You are not logged in

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


Mon 10 Apr 2017 06:01:25 PM UTC, comment #1: 

And that behavior of -printf is expected.  It is comparable to the POSIX behavior of -print.

The '-printf' expression (like POSIX -print) will print the file name being visited, then return true.

The '-type f' expression will check whether the file being visited as a regular file, and return true or false accordingly.

When two expressions are written as 'A B', find behaves if you had instead written 'A -a B'.  The -a operator is short-circuiting: if expression A returns false, expression B is not attempted; but if expression A returns true, then expression B is used.

When you write -printf first, it always executes (everything gets printed), then you filter out the files, but do nothing further with the files you filtered.

When you write -printf second, it only executes on the files that got past the -type filter.

Eric Blake <ericb>
Project Administrator
Mon 10 Apr 2017 05:18:08 PM UTC, original submission:  

These two cmds give diffrent results
find . -printf "%P\n" -type f
find . -type f -printf "%P\n"

The first one prints everything, the second only files

yan <yanpas>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ericb (Posted a comment)
  • -email is unavailable- added by yanpas (Submitted the item)

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

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-04-10 ericb StatusNone => Invalid
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.7