From: Chris Gregors (Chris.Gregors@TELUS.COM)
Date: Thu Apr 03 2003 - 14:01:02 EST
I never found a way to do it, so I wrote a shell function to walk
link-paths till it finds the real file behind the sym-link. It's kinda
crude, but it works everywhere.
#######################################################################
# Determine if $1 is a link to somewhere. Follow the link and any
# links that follow, and return the final REAL thing!
#
# NOTE: If the link chain points to a file that is not there,
then
# a filename of "BAD_LINK_FOLLOWED" will be returned
#######################################################################
ResolvFileLink() {
filename=$1
if [[ -L $filename ]] ; then
p=`ls -ld $filename | cut -c1`
if [ $p != "l" ] ; then
echo $filename
return
fi
while [ $p = "l" ] ; do
for fn in `ls -ld $filename` ; do
filename=$fn
done
p=`ls -ld $filename | cut -c1`
done
if [[ -f $filename || -d $filename ]] ; then
echo $filename
else
echo "BAD_LINK_FOLLOWED"
fi
else
echo $filename
fi
}
export ResolvFileLink
-----Original Message-----
From: Taylor, David [mailto:DTaylor@WBMI.COM]
Sent: Thursday, April 03, 2003 11:39 AM
To: aix-l@Princeton.EDU
Subject: Following symbolic links with find?
I saw references to this in the archive but could not find a clear
answer. Is there some way to get the find command to follow symbolic
links?
TIA,
David
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:43 EDT