2

One application sometimes, not very often, puts some incorrect (binary) characters in log. Only information that it matches is printed, no matched lines.

$ grep -e error app.log 
Binary file app.log matches

How can I grep the log simply omitting the binary characters?

less handles the file correctly, prints the binary characters as some escape sequences, so maybe some pipe less to grep will solve the issue.

1 Answer 1

1

You can tell grep to interpret the source file as a text file:

grep -a -e error app.log

Take into account that grep will not escape the binary characters so you should pipe the output to less or od -c to prevent possible negative effects of the characters to the terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .