Soft link pathname conversion for Linux and Unix
- From: John Horne <john.horne@xxxxxxxxxxxxxx>
- Date: Sat, 28 Apr 2007 19:42:59 +0100
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
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- Follow-Ups:
- Re: Soft link pathname conversion for Linux and Unix
- From: Sam Varshavchik
- Re: Soft link pathname conversion for Linux and Unix
- From: Steven W. Orr
- Re: Soft link pathname conversion for Linux and Unix
- Prev by Date: Re: Using Firefox in place of MS Explorer
- Next by Date: Re: [OT] Re: whats with this love of kaffiene?
- Previous by thread: Using Firefox in place of MS Explorer
- Next by thread: Re: Soft link pathname conversion for Linux and Unix
- Index(es):
Relevant Pages
|