On Thu, 14 Aug 2025 13:40:39 +0000 (UTC) RVP wrote: > 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 {} +
This is behaviorally different from OP's command in that test -x tests for executability by the process running it, not for "at least one execute bit set". That said, OP did also mention GNU find(1)'s -executable option which is AFAICT similar to test(1) in that respect, so it's unclear whether OP doesn't care or know about the difference. -- Štěpán