Posted By

ksaver on 08/03/11

Tagged

find

Viewed 3 times

Find duplicate files, using sha1 hash


/ Published in: Bash

URL: http://www.commandlinefu.com/commands/view/8958/find-duplicate-files-using-sha1-hash

Output Example:

d65bfef64a5fc9f7dbf9d35d80a2e1ed218c75d2 ./tmp1/12414.txt


d65bfef64a5fc9f7dbf9d35d80a2e1ed218c75d2 ./tmp2/2012.txt

d65bfef64a5fc9f7dbf9d35d80a2e1ed218c75d2 ./tmp1/3153.txt


dd07cec149e7c5929d6e9a0618de7114d50b34b0 ./tmp1/10064.txt

dd07cec149e7c5929d6e9a0618de7114d50b34b0 ./tmp2/30901.txt


d9bc21587f94d7a138bddf41cfa4e92a04cf9c54 ./tmp1/36.txt

d9bc21587f94d7a138bddf41cfa4e92a04cf9c54 ./tmp1/83.txt

[...]

  1. # Bash one-liner for find duplicate files
  2. # ksaver, Aug 2011
  3. # http://www.commandlinefu.com/commands/view/8958/find-duplicate-files-using-sha1-hash
  4. # Public Domain Code
  5. # Updated with some nice changes, now is smaller and faster... :-)
  6.  
  7. for i in $(find . -type f -exec sha1 -r {} \+ |tee .hashes.tmp |awk '{print $1}' |sort |uniq -d); do grep $i .hashes.tmp; echo; done;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.