I have a number of files in a directory, and I want to check that they are all unique. For simplicity, let's say I have three files:
baz.txt. If I run this loop, I will check them all against each other:
$ for f in ./*; do for i in ./*; do diff -q "$f" "$i"; done; done Files bar.txt and baz.txt differ Files bar.txt and foo.txt differ Files baz.txt and bar.txt differ Files baz.txt and foo.txt differ Files foo.txt and bar.txt differ Files foo.txt and baz.txt differ
For the hundreds of files I want to deal with, this would become pretty unreadable; it would be better to list the files that do match, and then I can look over the list quickly and make sure that files are only matching themselves. From the manpage, I would have thought that the
-s option would accomplish this:
$ for f in ./*; do for i in ./*; do diff -s "$f" "$i"; done; done Files bar.txt and bar.txt are identical Files baz.txt and baz.txt are identical Files foo.txt and foo.txt are identical
...however, in fact it also prints out the whole contents of any files that differ. Is there any way to suppress this behaviour, so I only get the behaviour above?
Alternatively, is there some other tool that can accomplish this?