Possible Duplicate:
Duplicate file finder

... to continue on the title, basically what I want is for me to give him the file, and the program goes through the whole project directory and seeks are there any files (they all differ in names, naturally :) that are binary same to the first one ...

It is in a way, diff, but I don't want to go through the project directory myself, since there are quite a lot of them.

| |
  • 2
    I suppose you could script some quick checksum based thing... or a duplicate file finding software... OS? – Journeyman Geek Nov 30 '11 at 3:07
  • @Paul - No, not the same as the question linked to. My files are of different names, and were you to cross-reference them by size, many ofther non-duplicate files would be included as well (they're all around 50-100kB). – Rook Nov 30 '11 at 22:03
  • @Paul - When I object to a duplicate-close, I don't observe every answer given in that question. I looked at the question, since your reason for closing was a "duplicate question", and dismissed it. Otherwise, we might start closing different questions that have mutual answers as well as duplicates. – Rook Nov 30 '11 at 22:59
  • This commentary is serving no purpose so I have deleted mine. The question has been raised at meta meta.superuser.com/questions/3771/… – Paul Dec 1 '11 at 20:55

Sorry, didn't see the OS tag before posting. But would work on Windows with Cygwin or UnxUtils as well.

The following command computes the MD5 checksums for all files in the project directory and displays those with the same checksum as a reference file:

find /path/to/project -type f -exec md5sum {} \; | grep $( md5sum /path/to/reference/file | cut -c1-32 ) | cut -c35-

The cut commands are used to extract the 32 character checksum (-c1-32) and the file name (-c35-) from the output of md5sum.

| |
  • I have some port of UnxUtils for windows, I'll try this approach. Thanks! – Rook Dec 1 '11 at 17:23
  • @ldigas UnxUtils is the port. Good luck! If you don't have a bash or similar shell, call md5sum /path/to/reference/file separately and use the returned checksum as argument to grep. – Daniel Beck Dec 1 '11 at 17:36
  • No, it is a port of UnxUtils (so they say). It's called UnitKitTiny ... don't know where I got it from though. – Rook Dec 1 '11 at 17:45
  • @ldigas Nice, didn't know about that one. UnixKitTiny though. Will have to check it out. – Daniel Beck Dec 1 '11 at 17:51

This works on Ubuntu 11.10:

for file in $(find $2 -type f)
    diff -s "$1" "$file" | grep "identical$"

It should work on any distro with bash, find and diff.

$ ./recursive_diff.sh 2.gif Pictures/
Files 2.gif and Pictures/qzhm4k.gif are identical
| |
  • Sorry, forgot to add that. Windows XP here. – Rook Nov 30 '11 at 4:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.