Binary file (standard input) matches

Saturday, July 12, 2008

One of the most important obligations for DBA's is regularly checking alert log file.

To help myself I've written shell script which connects to several unix machines and examines alert log files looking for ORA- errors or 'Checkpoint not complete' lines.

Script was working fine for several months but yesterday it reported 'Binary file (standard input) matches'.

I've searched for that error and found solution:

Why does grep report "Binary file matches"?

If grep listed all matching "lines" from a binary file, it would probably generate output that is not useful, and it might even muck up your display. So GNU grep suppresses output from files that appear to be binary files. To force GNU grep to output lines even from files that appear to be binary, use the `-a' or `--binary-files=text' option. To eliminate the "Binary file matches" messages, use the `-I' or `--binary-files=without-match' option.

Source :

In my script I'm using egrep and grep powerful unix tools to search for specified pattern, so my problem was there. I don't know what happened with that alert log file but grep supressed output like it was binary file.

To fix that problem I've added -a along the grep lines and everything worked fine.

I've found what was causing this error and fixed little bug in my script. On specified database server logrotate was started with compression option. I'm analyzing whole log files (rotated with logrotate also), so in this case I've tried to read compressed logfile with cat tool. As I was reading binary file with cat output was little fuzzy and unreadable. To fix this I've used less tool which shows compressed log file in decompressed version as a text. Now script works like a clock.



  • Thanks very much, this helped.

    Interestingly this occurred to me quite randomly, and sometimes neither -a nor the use of egrep helped.. o.O"

  • Marko Sutic


    I've had same problems with specifying -a in grep command.

    Luckily less reads everything :-)


  • use

    strings | grep

    i think this will be more easier...

  • Marko Sutic

    You're correct, strings with grep would work also.

    At that time I didn't knew about strings command.


  • Post a Comment