3
# Example script for duff(1).
5
# Copyright (c) 2005 Ross Newell
7
# Modified Jan 7, 2006 by Camilla Berglund <elmindreda@elmindreda.org>
9
# Uses duff to find duplicate physical files and changes them into hard links
10
# to a single physical file, thus saving disk space. Use with care.
13
if [ "$1" == '' ]; then
14
echo "usage: `basename $0` directory"
18
duff -r '-f#' -z -p -P "$1" |
22
if [ "$file" == '#' ]; then
25
if [ "$first" == '' ]; then
28
temp=`mktemp -p \`dirname $file\``
30
mv "$file" "$temp" && \
31
ln "$first" "$file" && \
32
touch --reference="$temp" "$file" && \
36
echo "`basename $0`: $file: failed to join with $first"
37
echo "`basename $0`: $file: may exist as $temp"