Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!mcnc!thorin!white!white From: white@white.cs.unc.edu (Brian T. White) Newsgroups: comp.unix.questions Subject: Re: How to find directory name at end of symbolic links Message-ID: <7177@thorin.cs.unc.edu> Date: 9 Mar 89 22:52:22 GMT References: <10@sherpa.UUCP> <9745@smoke.BRL.MIL> <304@unet.UUCP> Sender: news@thorin.cs.unc.edu Distribution: na Lines: 29 > I am using SunOs 3.5 and want to know how to find out the directory > name at the end of a series of symbolic links. > > Any ideas? Try this: #! /bin/csh -f foreach file ($argv[1-]) echo "" if (! -e $file) then echo $file does not exist continue endif echo "$file" set islink while ($?islink) set listing=`ls -ld $file` echo $listing | grep -s ^lrwx if ($status) then unset islink else set file=`echo $listing | awk '{print $NF}'` echo " -> $file" endif end end echo ""