Mailing List Archive

Support open source code!


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

Re: symlink destination



>>>>> "AS" == Antony Stace <antony@example.com> writes:

    AS> a bit of an overkill, but you could use find <the file you
    AS> want> -printf "%l"

Wonderful. One more reason why linux is better than HPUX. I should
have mentioned that I'm currently on the latter (it's TL(ove)U(nix)G
group, right?).

>>>>> "TOD" == Thomas O'Dowd <tom@example.com> writes:

    TOD> No way that I know to do with without a bit of shell
    TOD> programming. Here is an example of following more than one
    TOD> link to find the real name of a script. If you are dealing
    TOD> with a random file argument, then you also need to watchout
    TOD> for circular links...

    TOD> Tom.

    TOD> CMD=$0 while [[ -L "$CMD" ]] ; do ls=`/bin/ls -ld "$CMD"`
    TOD> link=`/usr/bin/expr "$ls" : '.*-> \(.*\)$'` if /usr/bin/expr
    TOD> "$link" : '/' > /dev/null; then CMD="$link" else
    TOD> CMD="`/usr/bin/dirname $CMD`/$link" fi done

This is probably what I want to do (sorry, my formatting made it
unrunnable).

Thanks, Tony, thanks, Tom.

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links