如何查找可执行文件


8

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


1
定义可执行文件?Linux中几乎每个文件都可以执行。
米奇

那些以./myfile类型运行的终端文件
Mohammad Reza Rezwani 2014年

我知道有-fstype,但是我不知道怎么办?
Mohammad Reza Rezwani 2014年

文件系统类型,fstype在Linux环境中使用,指出正在使用的文件系统类型。
米奇

@米奇好吧好吧,我想我可以用我在男人身上看到的那个。我的问题是如何找到那些文件,通过chmod + x myfile使它们可执行
Mohammad Reza Rezwani 2014年

Answers:


14

这应该做您想要的:

find . -perm -u+x -type f  

如果要查找可能可执行的所有内容,则可以查看mime类型或file输出。但是,这将适得其反,因为您不可能捕获所有脚本。

参考:
手册页
Stackoverflow


8

这也可以

find ~ -type f -executable

列出目录中的所有可执行文件/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.

@Raj thnka这个人正在工作
Mohammad Reza Rezwani 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.