Soft link pathname conversion for Linux and Unix

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

 



Hi,

I have a shell problem that I am trying to easily resolve. If I have a
directory with a soft (symbolic) link in it such as:

         fred -> ../bin/csh

How can I convert the '../bin/csh' in to a full pathname? Is there a
command to do this that will work for Linux and Unices? I need it to
work for all circumstances, not just this one particular example. So
something like '../../abc/../def' should also work in being converted.

Under Linux the 'readlink -f' command works fine, but NetBSD readlink
doesn't have the '-f' option, and Solaris doesn't have readlink. I do
not want to change directory at all, so changing to the link directory
and issuing 'pwd' isn't what I want to do.

My only other thought is to process the link pathname bit-by-bit.
Preceed the pathname with the current working directory and then remove
any './' and jiggle (!) with any '../' to get the directory above. It's
messy and could get complicated. Better ideas welcome :-)



Thanks,

John.

-- 
---------------------------------------------------------------
John Horne, University of Plymouth, UK  Tel: +44 (0)1752 233914
E-mail: John.Horne@xxxxxxxxxxxxxx       Fax: +44 (0)1752 233839


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux