在Unix中使用find命令时忽略“是一个目录”

我使用以下命令在目录结构中递归地查找字符串.
find . -exec grep -l samplestring {} \;

但是当我在一个大型目录结构中运行命令时,会有一个很长的列表

grep: ./xxxx/xxxxx_yy/eee: Is a directory
grep: ./xxxx/xxxxx_yy/eee/local: Is a directory
grep: ./xxxx/xxxxx_yy/eee/lib: Is a directory

我想省略上面的结果.只需显示带有字符串的文件名即可.有人可以帮忙吗?

每当你说find时,该实用程序将返回当前目录结构中的所有元素:文件,目录,链接……

如果你只是想找到文件,就这么说吧!

find . -type f -exec grep -l samplestring {} \;
#      ^^^^^^^

但是,您可能希望查找包含字符串的所有文件

grep -lR "samplestring"

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...