[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fdupes and hardlinking duplicate files

On Fri, Dec 17, 2004 at 07:30:24AM -0800, hcheney wrote:
} I have a rather large collection of files and there is a great deal of
} duplication in the tree. What I would like to do is replace all of the
} identical files with hardlinks - which I can't seem to do with fdupes.
} There is a Red Hat - Fedora rpm floating around called hardlink, but I
} can't seem to figure out how to use it. Any how, I really prefer to use a
} strictly woody/stable setup for my system.


fdupes -1 "$@" | sed -e 's/%/%0/g' -e 's/\\ /%1/g' |\
awk '{for (i=2;i<=NF;++i) printf("rm -f %s; ln -f %s %s\n", $i, $1, $i);}' |\
sed -e 's/%1/\\ /g' -e 's/%0/%/g' | sh

Note that this script will have problems with filenames containing
characters that are meaningful to the shell (e.g. quotes, ampersand, etc.).
It will also misbehave if you pass certain fdupes flags in as arguments
(-f, -S, and -d, at a minimum).

} Thanks for any advice or suggestions.
} ~Hcheney

Reply to: