Search for executable files using find command

前端 未结 10 866
既然无缘
既然无缘 2020-12-07 11:21

What type of parameter/flag can I use with the Unix find command so that I search executables?

10条回答
  •  半阙折子戏
    2020-12-07 12:09

    Well the easy answer would be: "your executable files are in the directories contained in your PATH variable" but that would not really find your executables and could miss a lot of executables anyway.

    I don't know much about mac but I think "mdfind 'kMDItemContentType=public.unix-executable'" might miss stuff like interpreted scripts

    If it's ok for you to find files with the executable bits set (regardless of whether they are actually executable) then it's fine to do

    find . -type f -perm +111 -print
    

    where supported the "-executable" option will make a further filter looking at acl and other permission artifacts but is technically not much different to "-pemr +111".

    Maybe in the future find will support "-magic " and let you look explicitly for files with a specific magic id ... but then you would haveto specify to fine all the executable formats magic id.

    I'm unaware of a technically correct easy way out on unix.

提交回复
热议问题