Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder myfolder that contains a huge hierarchy of files/folders.
How to find all executable files within this folder?

On Ubuntu this works: find . -executable -type f

But Mac OS X Mavericks (which also uses bash) fails to get it:

find: -executable: unknown primary or operator
share|improve this question
up vote 6 down vote accepted

This will find all files (not symlinks) with the executable bit set:

find . -perm +111 -type f

This will also find symlinks (which are often equally important)

find . -perm +111 -type f -or -type l

Here's how the command works if its not obvious:

  • find is obviously the find program (:
  • . refers to the directory to start finding in (. = current directory)
  • -perm +111 = with any of the executable bits set (+ means "any of these bits", 111 is the octal for the executable bit on owner, group and anybody)
  • -type f means the type is a file
  • -or boolean OR
  • -type l means the type is a symbolic link
share|improve this answer
You can use -L instead of -or -type l to cause any stat calls made by find to return the stats of the file linked to, not the link itself. – Ian C. Jan 8 '14 at 7:27
The problem I found with this approach is that any file can have the run permission. For example, after you download some text file from Windows, the permission is messed up. – Ivan Z. Xiao Oct 16 '14 at 20:54

From the man page for find in OS X:

 -perm [-|+]mode
         The mode may be either symbolic (see chmod(1)) or an octal number.  If the mode is symbolic, a
         starting value of zero is assumed and the mode sets or clears permissions without regard to the
         process' file mode creation mask.  If the mode is octal, only bits 07777 (S_ISUID | S_ISGID |
         S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO) of the file's mode bits participate in the comparison.
         If the mode is preceded by a dash (``-''), this primary evaluates to true if at least all of
         the bits in the mode are set in the file's mode bits.  If the mode is preceded by a plus
         (``+''), this primary evaluates to true if any of the bits in the mode are set in the file's
         mode bits.  Otherwise, this primary evaluates to true if the bits in the mode exactly match the
         file's mode bits.  Note, the first character of a symbolic mode may not be a dash (``-'').

So you need:

find . -type f -perm +0111 -print

Remember that OS X is BSD-based, not Linux based, so the Gnu commands you're used to in Linux distributions (of which find is one of them) aren't necessarily the same as they are in OS X. This isn't a shell difference, it's an operating system/operating system utility tools difference.

share|improve this answer

I couldn't make Ian's answer work (10.6.8), but, the following gave the expected results:

find . -type f -perm +0111 -print

edit update

This seems to work as well!

find . -type f -perm +ugo+x -print

I guess the "x" is meaningless without the user/group/other specifiers.

share|improve this answer
Symbolic syntax must be new -- thanks for pointing that out. I updated my answer so it uses octals and is backwards compatible with older OS X versions. – Ian C. Jan 8 '14 at 7:26
Oddly enough, that section of the 10.6 manpage is exactly the same as what you quoted.... which was enough to make me dig a little deeper and see what the heck was going on. Amended my response above. – Kent Jan 8 '14 at 7:49
Conclusion: BDS command syntax is weird. – Ian C. Jan 8 '14 at 7:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.