尝试grep日志文件时出现行太长错误

尝试grep日志文件时出现行太长错误

问题描述:

当我在shell提示符下键入此命令时:

When I type this at shell prompt:

grep -r  "ambiguously" .

我得到了错误:

grep:行太长.

grep: line too long.

基本上,当前目录是一个日志目录,我正在尝试在所有日志文件中找到sql错误歧义定义的列".

Basically the current directory is a log directory and I am trying to locate the sql error 'Column ambiguously defined' in all the log files.

但是为什么会出现错误?文件很大,是主要原因吗?

But why do I get the error? The files are very huge in size, is that the main reason?

您应该尝试

find -type f -exec grep PATTERN {} +

命令行限制可以在Linux上找到,

The command line limitation can be found on linux with

$ getconf ARG_MAX

在* BSD上

$ sysctl kern.argmax

请参见 http://www.cyberciti.biz/常见问题解答/参数列表过长的错误解决方案/.