使用find命令搜索可执行文件 [英] Search for executable files using find command

查看:850
本文介绍了使用find命令搜索可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Unix find命令中使用哪种类型的参数/标志,以便搜索可执行文件?

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

推荐答案

在GNU版本的find中,您可以使用-executable:

On GNU versions of find you can use -executable:

find . -type f -executable -print

对于find的BSD版本,可以将-perm+和八进制掩码一起使用:

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

find . -type f -perm +111 -print

在这种情况下,"+"表示已设置所有这些位",而111是执行位.

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

请注意,这与GNU find中的-executable谓词不同.特别地,-executable测试文件可以由当前用户执行,而-perm +111仅测试是否设置了任何执行权限.

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.

较旧的GNU版本也支持-perm +111语法,但是从 4.5.12 不再支持此语法.相反,您可以使用-perm /111来获得此行为.

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.

这篇关于使用find命令搜索可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆