NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Find all files with at least one execute bit set
RVP wrote in
<4a495fb2-150d-67b7-cbbc-8a799868d595%SDF.ORG@localhost>:
|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 :).
fwiw GNU find(1) has
-perm /mode
Any of the permission bits
-perm -mode
All of the permission bits
which then is pretty cool
|-RVP
--End of <4a495fb2-150d-67b7-cbbc-8a799868d595%SDF.ORG@localhost>
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Home |
Main Index |
Thread Index |
Old Index