BlogBlog ÜbersichtjailscriptportsoptFreeBSDLinksThermoskanneKontakt

Identische Dateien löschen

Mit Hilfe von samesame lassen sich Identische Dateien aufspüren und falls gewünscht löschen. Im FreeBSD-Portbaum findet man samesame unter sysutils/samesame:

# cd /usr/ports/sysutils/samesame && make install clean

Im folgenden Beispiel werden mit Hilfe von samefile identische Dateien gefunden und mit Hilfe von samerm jeweils alle bis auf eine der identischen Dateien gelöscht.

# ls -l
total 6
-rw-r--r--  1 test  wheel  8 28 Nov 13:59 a
-rw-r--r--  1 test  wheel  4 28 Nov 13:56 b
-rw-r--r--  1 test  wheel  4 28 Nov 13:58 c
# find . | samefile -i | samerm
# ls -l
total 4
-rw-r--r--  1 test  wheel  8 28 Nov 13:59 a
-rw-r--r--  1 test  wheel  4 28 Nov 13:56 b

Möchte man die Dateien nicht löschen, so kann mit sameln die Datei durch einen Hardlink ersetzt werden:

# ls -1i
16468 a
16469 b
16453 c
# find . | samefile -i | sameln
# ls -1i
16468 a
16469 b
16469 c

Mehr Informationen zu samesame findet man in den Manpages samesame(1), samefile(1) und sameln(1).

Comments (2)  Permalink

Comments

molli123 @ 28.11.2009 18:51 CEST
und bald ist es ein "zfs set dedup=on tank" ;-)
Alex de Kruijff @ 09.01.2010 03:54 CEST
(Sorry I don't know how to write in Germen.)

If you like to symlink the duplicates file that couldn't be hardlinked you could do the following:

find . | samefile -i | sameln | sameln -s

If you like to removing duplicates files and favor the files that are hardlinked more often you could do the following: (If A, B and C are duplicates and B and C are hardlinked, then A is removed.)

find . | samefile -iL | samerm -L

If you like to removing duplicates files and also like to include files that are hardlinked the do the following: (If A, B and C are duplicates and B and C are hardlinked, then B and C should be removed.)

find . | samefile -ir | samerm

Three advantages of samesame over "zfs a set dedup=on tank": you can avoid the overhead, you get to choice when to run the checks, and you can also run it on non-zfs filesystems.

add a comment

The Trackback URL to this post is:
http://www.chruetertee.ch/blog/plugin=trackback(1562).xml
Trackbacks are moderated.

This blog is gravatar enabled.
Your email adress will never be published.
Comment spam will be deleted!

Name*
E-Mail
For Spammers Only
URL
Comment*
Notify me via E-Mail when new comments are made to this entry
Remember me (needs cookies)