Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symlink destination



On Wed, 25 Oct 2000, Viktor Pavlenko wrote:

> 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.

#!/bin/sh

file=/path/to/file
dest=`perl -e "print readlink(\"$file\");"`

(Actually this is a subtle hint that perl makes this kind of scripting
easier... but it will work in a shell script if you have perl around.)
-- 
Tod McQuillin



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links