fd icon indicating copy to clipboard operation
fd copied to clipboard

RFE: Add --perm flag

Open kclevenger opened this issue 4 years ago • 3 comments

In conjunction with #328 (specifically the --owner option), please consider adding a --perm flag accepting the standard four digit permission format as a filter

kclevenger avatar Dec 31 '19 18:12 kclevenger

Thank you for your feedback.

I always a little hesitant to add new options to fd. This one in particular, because it would be OS specific.

accepting the standard four digit permission format

What do you mean by "standard four digit … format"? I am familar with the user/group/other three digit format (e.g. 644), but what would the fourth digit be?

Apart from that, I have several questions:

  • Most importantly: What are actual real world use cases where this option would be useful? If --perm 644 simply searches for files with permissions set to 644 exactly, I don't really see much use for this. I'd rather expect queries like "files/directories which are writable/readable by me" or "files/directories which are NOT writable/readable by me" to be useful.
  • find seems to have invented a whole new syntax for permission filters (-perm mode, -perm -mode, -perm /mode), which goes a long with the find-specific logic operations for negation, conjunction, disjunction, etc. I am not planning to implement such a complex logic system within fd. Is this option really going to be useful without all of this?
  • How are we going to deal with other operating systems? I'd really like to avoid having a completely UNIX-centric command line option like --perm UGO. find has several more options dealing with permissions (-readable, -writable), which sound a bit more appealing to me. Those could probably also be implemented in a OS-independent way(?).

sharkdp avatar Apr 11 '20 14:04 sharkdp

but what would the foruth digit be?

The fourth digit is actually the first one, which is usually omitted or 0. It is used for the setuid, setgid, and restricted-deletion/sticky flags. The chmod man page has more information on them.

tmccombs avatar Apr 12 '20 05:04 tmccombs

Might be related to #400.

FranklinYu avatar Jun 16 '20 07:06 FranklinYu

None of the questions above have been answered after two years. I'd like to close this for now.

sharkdp avatar Nov 21 '22 20:11 sharkdp

I just encountered a need for this. I needed to find all subdirectories in a tree that have 777 permissions.

fd \
  --full-path /the/root/dir \
  --max-depth 1 \
  --changed-after 2023-02-19 \
  --exec find {}/ -type d -perm 0777

I was surprised to discover that fd didn't have this baked in already and that I needed to effectively filter through ye olde find to accomplish it. Something in fd would scratch the itch, but an arbitrary filtration command provided by #400 would suffice, too.

colindean avatar Feb 20 '23 18:02 colindean

I also would use this feature: when copying between non-Unix filesystems like an exFAT flash drive and filesystems that support the Unix permission model, I often end up with files with broken permissions (777). It would be nice to search through my filesystem for these easily.

A workaround is to search for executable files using --type.

dryya avatar Jul 18 '23 15:07 dryya