grep: Binary file (standard input) matches

When we want to use grep on a binary file, we’d get errors like this,

$ cat /bin/cat | grep GLIBC
Binary file (standard input) matches

We can ask grep to take binary file as a text with the parameter “-a”, which is equivalent to the –binary-files=text option,

$ cat /bin/cat | grep -a GLIBC

Alternatively you can use the command strings to print strings of printable characters in binary file, then use grep. This will make the output beautiful,

$ strings /bin/cat | grep GLIBC

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.