How to find all executable files? (AIX)

5,703

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

Share:
5,703

Related videos on Youtube

webwesen
Author by

webwesen

Updated on September 17, 2022

Comments

  • webwesen
    webwesen almost 2 years

    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
    • Admin
      Admin about 15 years
      You want to do this from the command line or from a program?
    • Gordon Shephard
      Gordon Shephard about 15 years
      webwesen, can you retitle this to be "How to find all executable files on AIX?"
  • webwesen
    webwesen about 15 years
    I tried that before posting - does not work on AIX - at least. nothing is returned. $ uname -a AIX xyz 3 5 00000000000 $ find . -type f -perm +111 $ ||| sorry - formatting in comments is not supported apparently
  • Kiwy
    Kiwy over 10 years
    that doesn't work on AIX 6 at least for me