Find the answer to your Linux question:
Results 1 to 9 of 9
Hello, I'm trying to search executable files (from current and sub-directories included) using find. What is the correct syntax ? Or other preferred tools for a such research ? Thanks ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2008
    Location
    Luxembourg
    Posts
    135

    find : how to search executable files ?


    Hello,

    I'm trying to search executable files (from current and sub-directories included) using find.
    What is the correct syntax ?
    Or other preferred tools for a such research ?

    Thanks for help.
    Bruno

  2. #2
    Just Joined!
    Join Date
    Mar 2009
    Location
    Melbourne
    Posts
    17
    Hope this helps -
    http://www.linuxforums.org/forum/lin...ble-files.html

    ofcourse u will need to change the code a little bit, to make the search exclusive for the directory or sub directory want to check.

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    You'll want to use find with -perm

    man is your friend
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  4. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    find is indeed the correct program for this. However, you will run into an issue here.

    When you say "executable", what exactly do you mean? Do you mean executable for you? Or executable for anyone? Remember, a file can have its executable permission set for any combination of the owner, controlling group, or others.

    As a result, you'll have to play with the "-perm" flag to make sure that it's checking for _any_ of the permissions, not the exact permission.

  5. #5
    Linux User vickey_20's Avatar
    Join Date
    Mar 2009
    Location
    Mumbai, India
    Posts
    493
    use the find command with the -perm tag as pointed by others. If you want to search the current dir then put the path in the find commmand as the same.

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,174
    Quote Originally Posted by bcostacurta View Post
    I'm trying to search executable files (from current and sub-directories included) using find.
    What is the correct syntax ?
    Or other preferred tools for a such research ?
    Are you just searching for executable files, or for data inside executable files? The code to do the latter is VERY much different than the former, though they will have some similarities in the syntax used with the find command.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Linux Newbie
    Join Date
    Dec 2008
    Location
    Luxembourg
    Posts
    135
    Precisely, I'm looking for a way to search executable files only.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,174
    Quote Originally Posted by bcostacurta View Post
    Precisely, I'm looking for a way to search executable files only.
    Assuming you want to find particular strings inside of executables, then use the find command with the -perm option (read the find man page) and -exec option in conjunction with the strings command piped to grep -l to end up with a list of executable that contain the specific strings you are interested. I leave the exact syntax up to you as a learning exercise. Read the docs and man pages for details how to do this.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Linux Newbie
    Join Date
    Dec 2008
    Location
    Luxembourg
    Posts
    135
    (note: as described I'm not looking for a specific string inside executables).

    Indeed usage of 'find' with parameter -exec + needed options allows the research of only executables files.
    Thanks for attention.

    Bruno

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •