Solved: Binary file (standard input) matches grep error

Stephen Lee
Sep 2, 2022

--

Problem

I try to get all the text with trace id from the log file, but it report the following error:

$ grep traceId ~/logs/api.log 
Binary file (standard input) matches

Solution

To solve the problem we can add a -a parameter to grep command like below:

$ grep -a traceId ~/logs/api.log

The -a option means on the man document for grep:

-a, --text
Process a binary file as if it were text; this is equivalent to the --binary-files=text option.

--

--

Stephen Lee

I am a software engineer, I like to use the computer to solve problems. website: https://blog.y9i.cc/