How to find all executable files? (AIX)

example

-rwxr--r--    1 me     users             0 May 27 13:58 file_0
-rw-rwxrw-    1 me     users             0 May 27 13:58 file_1
-rw-rw-rwx    1 me     users             0 May 27 13:59 file_2
-rwxrwxrwx    1 me     users             0 May 27 14:02 file_3

I would need to list all 4 files in the current dir

  • AIX
  • non-gnu 'find', so "find . -executable" won't work

Solution 1:

find . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \)

worked for me. any other solutions?

Solution 2:

find . -type f -perm +111

From find(1):

-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 ("-").

Not specified in SUSv3, but portable across *BSD and Linux at least (I haven't tested others).