Register
It is currently Mon Nov 24, 2014 4:27 pm

Converting Symlinks - Absolute to Relative


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Fri Jan 18, 2008 10:45 am   

Joined: Fri Jan 18, 2008 10:35 am
Posts: 2
Hi all, is there a script done or a bash way to convert absolute to relative links in the current directory?

For example, I'm in my home directory ( /home/user ), I have a symlink /home/user/java that links to /home/straps/work/prog/java ... Is there a way to convert that link to ./work/prog/java ?

I need this because I'm a KDevelop and SVN user; SVN can save symlinks, but Kdevelop save the entire path, so when I checkout the repository on another PC, symlinks are not recognized...

Can this be a workaround?

Thanks all


Top
 Profile  
 PostPosted: Fri Jan 18, 2008 4:12 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hi Straps!

You should check out "symlinks". It's a utility for managing and manipulating symbolic links. It seems to be included with debian/ubuntu, but I'm not sure about other distros. here's an example of me testing what it sounds like you want to do:

Code:
## First I had to install it
root@ajax:~# apt-get install symlinks
Setting up symlinks (1.2-4.2) ...

## Then I had to see what it could do
root@ajax:~# symlinks -?
symlinks: scan/change symbolic links - v1.2 - by Mark Lord

Usage:  symlinks [-crsv] dirlist

Flags:  -c == change absolute/messy links to relative
        -d == delete dangling links
        -r == recurse into subdirs
        -s == shorten lengthy links
        -v == verbose (show all symlinks)

## Here's where I'm testing from
root@ajax:~# pwd
/root

## Let's make a test directory
root@ajax:~# mkdir -p some/dir/deeper/than/this

## and make an absolute link to it
root@ajax:~# ln -s /root/some/dir/deeper/than/this/ ./this

## symlinks finds it in "." and tells me it's absolute
root@ajax:~# symlinks -v .
absolute: /root/this -> /root/some/dir/deeper/than/this/

## First I tried -c, but it didn't do exactly what I wanted...
root@ajax:~# symlinks -c .
absolute: /root/this -> /root/some/dir/deeper/than/this/
changed:  /root/this -> ../root/some/dir/deeper/than/this

## Then I looked back at the usage...
root@ajax:~# symlinks -sc .
lengthy:  /root/this -> ../root/some/dir/deeper/than/this
changed:  /root/this -> some/dir/deeper/than/this

## Now it's perfect!
root@ajax:~# symlinks -v .
relative: /root/this -> some/dir/deeper/than/this



I hope this helps!
-Jeo


Top
 Profile YIM  
 PostPosted: Sat Jan 19, 2008 8:40 am   

Joined: Fri Jan 18, 2008 10:35 am
Posts: 2
Thanks very very much, it works now, thanks


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP