RandyTek RandyTek - 3 months ago 9
Linux Question

How to suppress binary file matching results in grep

When using grep in linux, the result always contains a lot of "binary file XXX matches", which I do not care about. How to suppress this part of results, or how to exclude binary files in grep?


There are three options, that you can use. "-I' is to exclude binary files in grep. Other are for line numbers and file names.

grep -I -n -H 

-I -- process a binary file as if it did not contain matching data; 
-n -- prefix each line of output with the 1-based line number within its input file
-H -- print the file name for each match

So this might be a way to run grep:

grep -InH your-word *