Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by Paul, JdeBP, Simon Sheehan, Nifle, ChrisF Dec 6 '11 at 11:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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). –  ldigas 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. –  ldigas 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

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
I have some port of UnxUtils for windows, I'll try this approach. Thanks! –  ldigas 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. –  ldigas 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:

#!/bin/bash
IFS="
"
for file in $(find $2 -type f)
do
    diff -s "$1" "$file" | grep "identical$"
done

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
share|improve this answer
    
Sorry, forgot to add that. Windows XP here. –  ldigas Nov 30 '11 at 4:05

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