1

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.

Rook
  • 24,289

2 Answers2

2

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.

Daniel Beck
  • 111,893
0

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
sml
  • 2,020