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

 
 

bug #50780: -type option after printf is ignored

Submitter:  yan <yanpas>
Submitted:  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
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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:
   
   
Comment:
   

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    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.13-4448.
    Corresponding source code