On Thu, 14 Aug 2025 at 04:13, Paul Ripke <s...@stix.id.au> wrote: > On Thu, Aug 14, 2025 at 12:15:25PM +0200, Rocky Hotas wrote: > > Hello! > > I'm trying to use find(1) in a POSIX way to list all the files (not > > directories) with at least one execute bit set. In other words, all > > the following modes should cause a match: > > > > -rwxr-xr-x 1 myuser wheel 6 Aug 14 11:46 file1 > > -rwxr--r-- 1 myuser wheel 7 Aug 14 11:46 file2 > > -rw-r-xr-- 1 myuser wheel 4 Aug 14 11:52 file3 > > -rw-r--r-x 1 myuser wheel 6 Aug 14 11:53 file4 > > -rwxr-xr-- 1 myuser wheel 6 Aug 14 12:10 file5 > > > > (also `rwxr--r-x' should match, and so on). > > > > The only way I found so far is the following: > > > > find /target_directory/ -type f -perm -001 -or -type f -perm -010 -or > -type f -perm -100 > > > > It seems to work, but it's somewhat cumbersome. In GNU find, there is a > > single dedicated option, `-executable'. > > Is there a more compact, but still POSIX, way to obtain the same > > result with NetBSD's find(1)? > > Minor simplification: > > find /target_directory/ -type f -and \( -perm -001 -or -perm -010 -or > -perm -100 \) > > I can't see any other options. > > As another aside, find(1)'s weird syntax was the reason I wrote find2, which is in othersrc/external/bsd/find2. The syntax for it looks like:
find2 'mode & 0111' /dir1/ /dir2/ ... Best, Alistair