Plainnotes

grep skips binary files and says so

2024-02-26 · 2 min readTools

grep error * in a log directory returns only Binary file xxx matches for some files.

The file contains non-text bytes — a NUL, invalid UTF-8 — so grep treats it as binary and reports the match without printing it.

Flags: grep -a forces text, the usual fix; grep -I does the opposite and skips binaries; --text is the long form of -a.

A NUL in a log usually means something wrote garbage, which is worth tracing rather than hiding with -a.

rg skips binaries too; rg -a overrides. When processing a directory blind, file * is faster than trying flags one at a time.