On Thu, 14 Aug 2025, Rocky Hotas wrote:
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.
[...]
find /target_directory/ -type f -perm -001 -or -type f -perm -010 -or -type f
-perm -100
Is there a more compact, but still POSIX, way to obtain the same
result with NetBSD's find(1)?
If not sticking to pure find(1):
Compact, but slow, and filenames cannot contain (')--single quotes.
$ find /dir/ -type f -exec sh -c "test -x '{}' && echo '{}'" \;
Slightly faster, and should handle weird filenames:
$ find /dir/ -type f -exec sh -c 'for f; do test -x "$f" && echo "$f"; done'
xxx {} +
Note the `xxx' above. It, or some other string, is reqd. there to supply a `$0'
for the shell. Of course, you would usually put all this in a shell script, then
`-exec' that :).
-RVP