+1 vote
in Operating Systems by (59.1k points)
What Linux command should I use to compare two files?

1 Answer

+2 votes
by (256k points)
selected by
Best answer

You can use the diff command to compare text files.

Here is an example to display the differences between file1 and file2.

diff file1 file2

Here is another example to compare file1 and file2 while ignoring differences in white space.

diff -w file1 file2

If the two files differ only in the number of spaces and tabs between words, the diff -w command does not consider the files to be different.