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
GLIBC_2.4
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.2.5

Leave a comment

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