What's the alternative for `find -type d` on Mac?
I think your find
does understand -type d
because this is required by POSIX. However the syntax you used:
find -type d
is not POSIX-compliant, thus not portable. The proper portable syntax is:
find path -type d
Linux versions of find
will assume ./
if you omit path
. On Mac find
expects something like this:
find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
You want -type
to be a part of expression
but your find
needs path
or -f path
in its command line arguments. Before it gets one, it tries to interpret other arguments as options, so your -type
is in fact -t -y -p -e
; there is no -t
option defined, thus illegal option -- t
.
(Compare this answer).
The solution is simple: specify a path
explicitly. Mac equivalent of Linux find -type d
is:
find ./ -type d
Note this works in Linux as well.