Aimed systems: Linux and OS X. Original code which works in Ubuntu 16.04 but not OS X, but follows unsuccessfully POSIX standards
gfind ~ ! -readable -prune -o -type f -name "*.tex"
where
!
is about Negation of a primary; the unary NOT operator.-readable
TODO this does not seem to be POSIX-prune
is about The primary shall always evaluate as true; it shall cause find not to descend the current pathname if it is a directory. If the -depth primary is specified, the -prune primary shall have no effect.-o
is about Alternation of primaries; the OR operator. The second expression shall not be evaluated if the first expression is true. That is if not, then this.-type
about type, here filef
-name
about filename, here*.tex
Output
gfind: paths must precede expression: type
Usage: gfind [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Fix proposal
Use -perm 0744
instead of -readable
but not sure if it is equivalent
gfind ~ ! -perm 0744 -prune -o -type f -name "*.tex"
Output: /Users/masi
. Expected output: list of .tex files.
How can you set permissions of find correctly for readable?
Best Answer
The double negation at the beginning makes this rather complex. Just using
should work.
PS: Or
find . -perm +0666 -type f -name '*.tex'
for the defaultfind
.