Tuesday, February 1, 2022

[SOLVED] How to suppress binary file matching results in grep

Issue

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


Solution

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 *


Answered By - user184968
Answer Checked By - Mary Flores (WPSolving Volunteer)