[clue] convert softlinks to hardlinks

Chris Fedde chris at fedde.us
Tue Jul 31 21:10:29 MDT 2012


I'm not familiar with a command that does what you want.  Here is one
I whipped up in perl that might do.
Save it as say sym2hard, make it executable then run it as 'sym2hard symname'

#!/usr/bin/env perl

use strict;
use warnings;

my $s = $ARGV[0];
-l $s or exit 0;
my $f = readlink($s);
unlink $s;
link $f, $s'

It does very little in the way of edge case checking. For example it
may have interesting effects if the symlink points to a directory.
And it will not work of the symlink and the file are on different file
systems. If you have a list of the symlinks that need converting in a
text file then it is pretty easy to automate that:

while read f; do sym2hard $f; done < list_of_symlinks

But I'd be sure to do a bit of testiung before I just ran that command line.

On Tue, Jul 31, 2012 at 3:39 PM, Yaverot <Yaverot at computermail.net> wrote:
> So I was using a duplicate file finder, and after awhile I noticed I was using the softlink option instead of the (non-existant) hard-link option I wanted.
>
> So is there an easy tool/command that can convert softlinks to hardlinks? I don't want to say yes ~4354 times (if it asks by file), but I also know there are about 20 "no"s where I want the softlink.
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue


More information about the clue mailing list