[geeks] listing identical files

Phil Stracchino alaric at caerllewys.net
Fri Nov 19 13:24:22 CST 2004


On Fri, Nov 19, 2004 at 12:56:15PM -0500, Kevin wrote:
> Anyone know of a way of listing all the identical files in a
> directory?
> 
> I have a directory containing several large files, many of which
> are just duplicates with differing names.  I would like to find a
> way to list all the identical files to help rescue some drive
> space.

This is a little involved and messy, but:

md5sum * 2>/dev/null | sort > foo
cat foo | cut -d\  -f1 > foo2
cat foo2 | sort -u > foo3
for f in `diff foo2 foo3 | cut -d\  -f2`; do grep $f foo; done

should show you all duplicates.  It's up to you to determine from there
which are hardlinks, which are symlinks, and which are duplicates.




-- 
  ========== Fight Back!  It may not be just YOUR life at risk. ==========
  alaric at caerllewys.net : phil-stracchino at earthlink.net : phil at novylen.net
   phil stracchino : unix ronin : renaissance man : mystic zen biker geek
     2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)
           Linux Now!  ...Friends don't let friends use Microsoft.



More information about the geeks mailing list