错误:“grep:参数列表太长" [英] Error: "grep: Argument list too long"
本文介绍了错误:“grep:参数列表太长"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行以下命令,但出现参数太长错误.你能帮忙吗?
I am trying to run the following command, but gets argument too long error. Can you help?.
HOST# grep -rl 'pattern' /home/*/public_html/*
-bash: /bin/grep: Argument list too long
有没有办法覆盖这个错误并在所有用户 public_html 目录中 grep 我想要的模式匹配文件.同一台服务器上大约有 500 多个用户.
Is there a way to override this error and grep the pattern matching files I want in all users public_html directory. There are around 500+ users in the same server.
推荐答案
使用find
find /home/*/public_html -type f -exec grep -l 'pattern' {} +
+
修饰符使其将文件名分组为可管理的块.
The +
modifier makes it group the filenames in manageable chunks.
但是,您可以使用 grep -r
来完成.这个参数应该是目录名,而不是文件名.
However, you can do it with grep -r
. The arguments to this should be the directory names, not filenames.
grep -rl 'pattern' /home/*/public_html
这将只有 500 多个参数,而不是数千个文件名.
This will just have 500+ arguments, not thousands of filenames.
这篇关于错误:“grep:参数列表太长"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文