Symbolic links and Bourne shell...
Jeff Beadles
jeff at onion.pdx.com
Sun Sep 9 10:12:29 AEST 1990
boysko at dsrgsun.CES.CWRU.Edu (Glenn Boysko) writes:
>
>In Bourne shell, how can you find the path pointed to be a symbolic link?
>
>In C shell, you can type:
>
> % set linkpath = "`cd $SYMLINK; pwd`"
>
>However, in Bourne shell, pwd returns the same value as SYMLINK. Does anyone
>know how to get this info in a Bourne shell without typing:
>
> % linkpath="`csh -c 'cd $SYMLINK; pwd'`"
Well, here's a different way. The 'ls' command has an option 'L' that should
tell you the information that you need. An excerpt from TFM...
...
-L If argument is a symbolic link, list the file or
directory the link references rather than the link
itself.
...
Ie:
% touch /usr/tmp/foo
% ln -s /usr/tmp/foo ./bar
% ls -L ./bar
/usr/tmp/foo
% ^D
Your mileage may vary. I know that this does not work on all systems. 4.3BSD
is broken. :-(
If you have this option, you can do the following:
linkpath="`ls -L $SYMLINK`"
-Jeff
--
Jeff Beadles jeff at onion.pdx.com jeff at quark.wv.tek.com
More information about the Comp.unix.questions
mailing list