Apple - Find all executable files within a folder in terminal

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

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.


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.