Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: symlink destination
- To: tlug@example.com
- Subject: Re: symlink destination
- From: "Thomas O'Dowd" <tom@example.com>
- Date: Wed, 25 Oct 2000 15:27:12 +0900
- Content-Disposition: inline
- Content-Type: text/plain; charset=us-ascii
- In-Reply-To: <14838.29947.837620.510820@example.com>; from vp@example.com on Wed, Oct 25, 2000 at 02:51:55PM +0900
- References: <14838.29947.837620.510820@example.com>
- Reply-To: tlug@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <9OyYUC.A.Ed.vFo95@example.com>
- Resent-Sender: tlug-request@example.com
- User-Agent: Mutt/1.2.4i
On Wed, Oct 25, 2000 at 02:51:55PM +0900, Viktor Pavlenko wrote: > A shell programming question: > > Is there a way to find out the destination of a symbolic link (the > file it links to) from a sh script? Parsing the output of `ls -l' is a > possibility but it doesn't feel right. > > Thanks. > > Viktor Hi Viktor, No way that I know to do with without a bit of shell programming. Here is an example of following more than one link to find the real name of a script. If you are dealing with a random file argument, then you also need to watchout for circular links... Tom. CMD=$0 while [[ -L "$CMD" ]] ; do ls=`/bin/ls -ld "$CMD"` link=`/usr/bin/expr "$ls" : '.*-> \(.*\)$'` if /usr/bin/expr "$link" : '/' > /dev/null; then CMD="$link" else CMD="`/usr/bin/dirname $PRG`/$link" fi done -- Thomas O'Dowd Have you had your noop today? tom@example.com http://www.nooper.com
- Follow-Ups:
- Re: symlink destination
- From: "Thomas O'Dowd" <tom@example.com>
- Re: symlink destination
- From: "A.Sajjad Zaidi" <sajjad@example.com>
- References:
- symlink destination
- From: Viktor Pavlenko <vp@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: symlink destination
- Next by Date: Re: nohup
- Prev by thread: Re: symlink destination
- Next by thread: Re: symlink destination
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links