Diff command along with Grep gives “Binary file (standard input) matches”

From man grep:

-a, –text

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

–binary-files=TYPE

If the first few bytes of a file indicate that the file contains binary data, assume that the file is of type TYPE. By default, TYPE is binary, and grep normally outputs either a one-line message saying that a binary file matches, or no message if there is no match. If TYPE is without-match, grep assumes that a binary file does not match; this is equivalent to the -I option. If TYPE is text, grep processes a binary file as if it were text; this is equivalent to the -a option. Warning: grep –binary-files=text might output binary garbage, which can have nasty side effects if the output is a terminal and if the terminal driver interprets some of it as commands.

grep scans the file, and if it finds any unreadable characters, it assumes the file is in binary. Add -a switch to grep to make it treat the file a readable text. Most probably your input files contain some unreadable characters.

diff <(sed ‘1d’ ‘todayFile.txt’ | sort ) <(sed ‘1d’ yesterdayFile.txt | sort ) | grep “^<“

Wouldn’t be comm -13 <(...) <(...) faster and simpler?

Leave a Comment

error code: 523