Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command.

ls -l `find Test/ -perm /u=x,g=x,o=x -type f`

Is this a good/right/quick command or not?

My solution is:

find Test/ -executable -type f -exec ls -l {} \;

and got the same result as warl0ck and pradeepchhetri offered.

share|improve this question
    
You might want to check my updates ... –  warl0ck Mar 31 '13 at 10:19
2  
try find ... -exec -ls -l {} \+ instead of \; - doing that will cause only one ls command to be generated with multiple filename args, similar to how xargs works. read the find man page and search for -exec for details. –  cas Mar 31 '13 at 10:23
add comment

3 Answers

up vote 3 down vote accepted

Not really, you can integrate the ls command with find,

find Test/ -type f -perm /u=x,g=x,o=x -exec ls -l {} \;

UPDATE

Actually -executable is not an equivalent of -perm /u=x,g=x,o=x. You might have files that is executable only by the group or others, which will not be displayed.

So, depends on your purpose, if you want files executable only by you, that's okay to use -executable.

share|improve this answer
    
thanks. After I have gotten over 15 reputation, I'll vote up. –  Maksim Dmitriev Mar 31 '13 at 10:05
    
thank you for the updated comment. It's useful! –  Maksim Dmitriev Mar 31 '13 at 14:55
add comment

You should use -exec argument of find command.

$ find Test/ -perm /u=x,g=x,o=x -type f -exec ls -l {} \;
share|improve this answer
    
thanks. I'll vote up your answer later. Now I don't have 15 reputation. –  Maksim Dmitriev Mar 31 '13 at 10:06
    
@RedPlanet If you accept an answer, you will have enough reputation to upvote. –  Bernhard Mar 31 '13 at 10:31
add comment

There is no need to use -exec, as find comes with a -ls flag.

$ find Test/ -perm /u=x,g=x,o=x -type f -ls

From the man page:

-ls True; list current file in ls -dils format on standard output. The block counts are of 1K blocks, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. See the UNUSUAL FILENAMES section for information about how unusual characters in filenames are handled.

share|improve this answer
add comment

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.