Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
You want to do this from the command line or from a program? –  jeffamaphone May 27 '09 at 20:22
    
webwesen, can you retitle this to be "How to find all executable files on AIX?" –  Gordon Shephard May 29 '09 at 3:46

3 Answers 3

up vote 5 down vote accepted
find . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \)

worked for me. any other solutions?

share|improve this answer
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|improve this answer
    
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 –  webwesen May 28 '09 at 19:55
    
that doesn't work on AIX 6 at least for me –  Kiwy Dec 27 '13 at 14:57

Well, if you like Rube Goldberg devices, you could use:


ls -l | grep '^[^d]\(..x\|.\{5\}x\|.\{8\}x\)' | awk '{ print $8 }'

Though this only lists the current directory.

share|improve this answer

Your Answer

 
discard

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.