I have a number of files, I want to check that all those files have the same content.
What command line could I use to check that?
Usage could be something like:
$ diffseveral file1 file2 file3 file4
Result:
All files equals
OR
Files are not all equals
Best Answer
With GNU diff, pass one of the files as an argument to
--from-file
and any number of others as operand:You can use globbing as usual. For example, if the current directory contains
file1
,file2
,file3
andfile4
, the following example comparesfile2
,file3
andfile4
tofile1
.Note that the “from file” must be a regular file, not a pipe, because diff will read it multiple times.