tags:

views:

66

answers:

3

hi all

I used the following syntax in order to find IP address under /etc

(answered by Dennis Williamson in superuser site)

but I get the message "grep: line too long" someone have idea how to ignore this message and why I get this? Lidia

  grep -Er '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>' /etc/
  grep: line too long
A: 

Use find to build a list of files to grep,

find /etc -type f -print0 | xargs -r0 grep -E '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>'

In general find is a more flexible way of traversing the filesystem and building lists of files for other programs.

jmtd
The error message does not come from the shell, i.e. it is not a problem of an argument list, which got too long.
maxschlepzig
Yes, and find/xargs are often used to solve *that* problem. This isn't that problem, but using find/xargs solves it nonetheless.
jmtd
A: 

Perhaps your grep has a bug and scans by accident a binary file with too long lines (i.e. too much characters for grep to handle between two newlines). See this red hat page for more details.

maxschlepzig
A: 

This is a question for SuperUser.com (as alluded to in your question).

The reason why you get it is clear from the message, grep is being passed a line that is too long (from one of the files under /etc).

How to avoid it? Redirect Standard Error to /dev/null:

 grep -Er '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>' /etc 2>/dev/null
Johnsyweb