如何找到可执行文件

Moh*_*ani 10 find

我知道有一个查找开关。但我想知道如何搜索特定类型的文件。例如,我需要一种仅搜索可执行文件的终端命令。

Rob*_*ans 14

这应该做你想做的:

find . -perm -u+x -type f  
Run Code Online (Sandbox Code Playgroud)

如果您想找到可能可执行的所有内容,您可以查看 mime-types 或fileoutput。但这会适得其反,因为您不可能捕捉到每个脚本。

参考:
手册页
Stackoverflow


Avi*_*Raj 10

这也有效,

find ~ -type f -executable
Run Code Online (Sandbox Code Playgroud)

列出目录中的所有可执行文件/home/$USER

man find

-executable
          Matches files which are executable  and  directories  which  are
          searchable  (in  a file name resolution sense).  This takes into
          account access control lists  and  other  permissions  artefacts
          which  the  -perm  test  ignores.   This  test  makes use of the
          access(2) system call, and so can be fooled by NFS servers which
          do UID mapping (or root-squashing), since many systems implement
          access(2) in the client's kernel and so cannot make use  of  the
          UID  mapping  information held on the server.  Because this test
          is based only on the result of the access(2) system call,  there
          is  no  guarantee  that  a file for which this test succeeds can
          actually be executed.
Run Code Online (Sandbox Code Playgroud)