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.

The following command works on Ubuntu (GNU findutils 4.4.2) but not on Fedora (4.2.27)

time find . -maxdepth 1 -type f -executable -print

How do I find executable files using older version of find?

share|improve this question

4 Answers 4

up vote 6 down vote accepted
find . -maxdepth 1 -type f -perm /a+x

From the man:

-perm /mode

Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify ’u’, ’g’ or ’o’ if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test currently matches no files. However, it will soon be changed to match any file (the idea is to be more consistent with the behaviour of perm -000).

The EXAMPLES section has something where the find shows all writable files. A find on executable files will be similar to the given example.

share|improve this answer
find . -type f -perm -111

Note: -111 not 111

share|improve this answer
find . | file -f - | grep executable

might be much slower, but also will look for things that are executables, but not necessarily permissioned as such. You may need to change what you grep for to improve accuracy (this would also match a file called "executable.jpg") narrow results (you may only be looking for a certain type of exe) and you might want to prettify the output later.

Really would be useful to know why you are doing this in order to construct the best answer :)

share|improve this answer
    
This will find files that might be executable, but not files that are executable. –  Christoffer Hammarström Apr 19 '12 at 12:10
    
indeed it will - as I said, all files that are executables (you put it more cleanly!). We don't know what the OP is up to, so I thought let's have a bit of variety in answers ;) –  Tom Newton Apr 20 '12 at 8:29
time find . -maxdepth 1 -type f -perm /a=x -print
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.