From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Christian Wessely Newsgroups: gmane.os.tru64.managers Subject: SUMMARY: fdupes / how to find dupe files Date: Fri, 14 Jun 2002 08:50:17 +0200 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: <200206140645.g5E6jSA23070@tom.kfunigraz.ac.at> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1024037175 13817 127.0.0.1 (14 Jun 2002 06:46:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 14 Jun 2002 06:46:15 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.33 #1 (Debian)) id 17Ikqc-0003aj-00 for ; Fri, 14 Jun 2002 08:46:15 +0200 Original-Received: (qmail 2438 invoked by uid 5); 14 Jun 2002 06:46:01 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 2430 invoked from network); 14 Jun 2002 06:46:01 -0000 Original-Received: from unknown (HELO emroute2.cind.ornl.gov) (128.219.159.41) by 0 with SMTP; 14 Jun 2002 06:46:01 -0000 Original-Received: from emroute2.cind.ornl.gov (LOCALHOST [127.0.0.1]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GXO0024CO4OTM@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 14 Jun 2002 02:46:01 -0400 (EDT) Original-Received: from jerry.kfunigraz.ac.at (GIGAJERRY.kfunigraz.ac.at [143.50.55.161]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GXO001EHO3TBZ@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 14 Jun 2002 02:45:30 -0400 (EDT) Original-Received: from tom.kfunigraz.ac.at (mc_tom [10.10.1.160]) by jerry.kfunigraz.ac.at (8.11.2/8.11.2) with ESMTP id g5E6jSi25648 for ; Fri, 14 Jun 2002 08:45:28 +0200 (MET DST) Original-Received: from fnth16 (FNTH16.kfunigraz.ac.at [143.50.105.16]) by tom.kfunigraz.ac.at (8.11.2/8.11.2) with SMTP id g5E6jSA23070 for ; Fri, 14 Jun 2002 08:45:28 +0200 (MET DST) X-Sender: wessely@email.kfunigraz.ac.at Original-To: tru64-unix-managers@ornl.gov X-Mailer: QUALCOMM Windows Eudora Pro Version 4.0 Xref: main.gmane.org gmane.os.tru64.managers:572 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:572 Hi Admin Wizards, A big thanx to the list - once again, helpful responses within hours (or even minutes). The best solution for my problem was (1), but I the other responses are highly appreciated - I learned much from these. Credits go to (in order of appearance): James Sainsbury, Joerg Bruehe, Alan@Nabeth, Charles Ballowe Solutions: ----------------------------------------------------------------------- 1) make fdupes "makeable" (by James Sainsbury): The reason the compile doesn't proceed is that the header and object files for getopt_long() do not exist on tru64. One solution: goto your source/compile directory for gnu tar (1.13) look in lib for getopt.h getopt.o getopt1.o copy these to your fdupes compile directory edit the fdupes Makefile .... #EXPERIMENTAL_RBTREE = -DEXPERIMENTAL_RBTREE INCLUDES=-I. LIBES=getopt.o getopt1.o DEBUG=-O2 CFLAGS=$(INCLUDES) $(LIBES) $(DEBUG) .... fdupes: fdupes.c md5/md5.c $(CC) fdupes.c md5/md5.c $(CFLAGS) -o fdupes -DVERSION=\"$(VERSION)\" $( EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE) ---------------------------------------------------------------------------- ----------- 2) Shellscript that could do the job (Charles Ballowe): something like: find /directory-of-big-storage -exec cksum {} >> /tmp/output \; sort -n /tmp/output > /tmp/output.sorted and then something to go over and compare the first two fields of each line with the previous line to determine if the files are likely to be the same. It's going to take a while and beat on the disk a bit, but it will get the job done. (and since it's sorted output - you only have to worry about the lines next to the current line.) ----------------------------------------------------------------------- 3) Joerg Bruehe offered a script he has: I have a tool (shell script) that traverses two trees, "old" and "new", gets the file names from "old", looks for a file with identical name in "new", compares them, and (if equal contents) replaces the file in "new" by a hardlink to that in "old". (Mail me if you want that script.) Once things were even worse: We had changed several names. In that moment I did (unchecked - from memory): cd common_tree_root find . -type f -print | \ xargs ls -ldi | sort -n +6 -n +1 > list where the "sort" is on the size field first, inode second. >From there I proceeded manually ("cmp" on files with same size but different inodes, possibly followed by "ln -f"), but this might be a start point for automation. ---------------------------------------------------------------------------- ----- 4) and Alan@Nabeth suggested to: 1. Get a list of all the regular file names on the target file system: find /file-system -type f -print > list 2. Run the checksum program against each file. This will give you tuples of checksum, size and file name. Files with the size and checksum may be the same. xargs < list sum > checksums The next substep is a bit more complicated. You want to compare the checksums and sizes. You can almost do this with sort and uniq, but since the name is part of the line everything will be different. A custom awk or perl script might do the job. 3. For files that had the same size (non-zero) and checksum, compare them with diff or cmp. The checksum calculation with sum(1) is only 16 bits. You can have files with the same checksum that are different. cksum(1) uses a 32 bit checksum, which should give a better first cut separation before having to do detailed compares. ---------------------------------------------------------------------------- --------- YS, CW ------------------------------------------ Dr. Christian Wessely christian.wessely@uni-graz.at url: www-theol.uni-graz.at