Why doesn’t grep ignore binary files by default

grep

The manpage for grep describes the -I flag as follows:

-I      Ignore binary files.  This option is equivalent to 
        --binary-file=without-match option.

It also says this about binary files:

 --binary-files=value Controls searching and printing of binary files.
         Options are binary, the default: search binary files but do not print
         them; without-match: do not search binary files; and text: treat all
         files as text.

I cannot think of a scenario where I would care about matches in binary files. If such a scenario exists, surely it must be the exception rather than the norm. Why doesn't grep ignore binary files by default rather than requiring setting this flag to do so?

Best Answer

Not everything that grep thinks is a binary file, is actually a binary file. e.g. puppet's logs have ansi color coding in them, which makes grep think they're binary. I'd still want to search them if I'm grepping through /var/log though.

Related Question