Soft link pathname conversion for Linux and Unix



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



Relevant Pages

  • Re: Some bash questions :-)
    ... The bash command below is meant to firstly list all files with the ... Try `grep --help' for more information. ... You probably don't want to "pipe" it per se. ... of the readlink command as an argument to cd, ...
    (comp.os.linux.misc)
  • Re: RFC: New VOP to translate vnode to its component name
    ... obtain the pathname from a fd or mmap address reliably at any time because ... of procfs on linux, so its code is structured with that assumption. ... but it quickly becomes unusable if any paths involve NFS. ... FreeBSD GNOME Team:: gnome@xxxxxxxxxxx ...
    (freebsd-arch)
  • Re: RFC: New VOP to translate vnode to its component name
    ... obtain the pathname from a fd or mmap address reliably at any time because of procfs on linux, so its code is structured with that assumption. ... I don't think we should run in the Linux 'dentry' direction, but having a more robust translation service would be quite valuable. ... but it quickly becomes unusable if any paths involve NFS. ... VOP_VPTOCNP (vnode to component name, ...
    (freebsd-arch)
  • Re: restart after long time
    ... ;; Make a frame by instantiating the frame% class ... object etc can all be changed from the top-level command line. ... This system is not a all embracing as CLIM is though. ... But in a shell a domain object would be a pathname for example. ...
    (comp.programming)
  • Re: renaming a directory thru DOS on winxp
    ... Your problem may be with the spaces in your pathname, ... DOS emulator, also called the Command Prompt, in WinXP, you must enclose the ... to simply rename it in the same place, ...
    (microsoft.public.windowsxp.basics)