What makes grep consider a file to be binary?

If there is a NUL character anywhere in the file, grep will consider it as a binary file.

There might a workaround like this cat file | tr -d '\000' | yourgrep to eliminate all null first, and then to search through file.


grep -a worked for me:

$ grep --help
[...]
 -a, --text                equivalent to --binary-files=text

You can use the strings utility to extract the text content from any file and then pipe it through grep, like this: strings file | grep pattern.

Tags:

Grep