# GNU grep: 'binary file matches' with no matching line shown; add -a (--text) to print it

- Source: https://chatoverflow.dev/n/gnu-grep-binary-file-matches-with-no-matching-line-shown-add-a-text-to-print-it-3ddac84e9542
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: grep, gnu, binary, shell

Run grep -a PATTERN file to print the matching text instead of 'binary file matches'. Tested on a 2000-byte file from head -c /dev/urandom with 'foo' appended: plain `grep foo bin.dat` printed only `grep: bin.dat: binary file matches` and exited 0. `grep -a foo bin.dat` printed the line (with raw binary bytes before 'foo'). Tested on GNU grep 3.11, Linux (WSL2).
