आप readlink -f foo
का उपयोग करके सापेक्ष पथ को पूर्ण पथ में बदल सकते हैं। तो अगर आप की तरह कुछ करना होगा:
ln -s $(readlink -f $origlink) $newlink
rm $origlink
संपादित करें:
मैंने देखा है कि आप पथ रिश्तेदार रखना चाहते हैं। इस मामले में, लिंक को स्थानांतरित करने के बाद, आप पूर्ण पथ को सापेक्ष पथ में वापस बदलने के लिए symlinks -c
का उपयोग कर सकते हैं।
use strictures;
use File::Copy qw(mv);
use Getopt::Long qw(GetOptions);
use Path::Class qw(file);
use autodie qw(:all GetOptions mv);
my $target;
GetOptions('target-directory=s' => \$target);
die "$0 -t target_dir symlink1 symlink2 symlink3\n" unless $target && -d $target;
for (@ARGV) {
unless (-l $_) {
warn "$_ is not a symlink\n";
next;
}
my $newlink = file(readlink $_)->relative($target)->stringify;
unlink $_;
symlink $newlink, $_;
mv $_, $target;
}
स्रोत
2011-12-15 16:24:55
आप अभी भी लिंक प्रतीकात्मक जब ले जाया होने के लिए करना चाहते हैं? आपके द्वारा प्राप्त उत्तरों पर इसका प्रभाव पड़ता है। – fge
और क्या आप अभी भी लिंक को सापेक्ष पथों में रखना चाहते हैं, या उन्हें पूर्ण पथ में बदल रहे हैं ठीक है? –
मुझे लगता है कि यह unix.stackexchange.com पर है, हालांकि superuser.com भी काम करेगा। –