Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeff From: jeff@onion.pdx.com (Jeff Beadles) Newsgroups: comp.unix.questions Subject: Re: Symbolic links and Bourne shell... Keywords: pwd, ls, ln -s Message-ID: <1990Sep9.001229.16144@onion.pdx.com> Date: 9 Sep 90 00:12:29 GMT References: <19417@well.sf.ca.us> <1990Sep7.140159.4832@usenet.ins.cwru.edu> Organization: Little to none. Lines: 38 boysko@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@onion.pdx.com jeff@quark.wv.tek.com