Search for executable files using find command

前端 未结 10 855
既然无缘
既然无缘 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:20

    On GNU versions of find you can use -executable:

    find . -type f -executable -print
    

    For BSD versions of find, you can use -perm with + and an octal mask:

    find . -type f -perm +111 -print
    

    In this context "+" means "any of these bits are set" and 111 is the execute bits.

    Note that this is not identical to the -executable predicate in GNU find. In particular, -executable tests that the file can be executed by the current user, while -perm +111 just tests if any execute permissions are set.

    Older versions of GNU find also support the -perm +111 syntax, but as of 4.5.12 this syntax is no longer supported. Instead, you can use -perm /111 to get this behavior.

提交回复
热议问题