. Advertisement .
..3..
. Advertisement .
..4..
I have the following program code, but I do not know how to find the correct result. Why has this problem occurred, and how can it be solved? Here is the code that I am running:
diff <(sed '1d' 'todayFile.txt' | sort ) <(sed '1d' yesterdayFile.txt | sort ) | grep "^<" >> 'diff.TXT'
diff <(sed '1d' 'todayFile.txt' | sort ) <(sed '1d' yesterdayFile.txt | sort ) > temp.txt
grep "^<" temp.txt
Binary file (standard input) matches
And this is the error text I receive:
Binary file (standard input) matches
The cause: By standard, TYPE is binary, and if a binary file matches,
grep
normally gives a single line of message, and vice versa.grep
thinks that a binary file does not match if TYPE is without-match; this is similar to the -I option. Your input files most likely contain some unintelligible characters.Solution:
grep
analyzes the file and thinks it’s in binary mode if it detects any illegible characters. To makegrep
treat the file as readable text, you should insert the-a
switch. For example:comm -13 <(...) <(...)