[ale] Does anyone have a definitive way of determining the target of a soft link in bash?

David Tomaschik ozone at webgroup.org
Tue Aug 21 11:09:19 EDT 2007


Perhaps 'readlink' would be useful?

David


Charles Shapiro wrote:
> Hmm. Last time I did this I just parsed out the content of "ls -l":
>
> target=`ls -ltr ${LINK} | awk -F'>' '{print $2}'`
>
> Not pretty, I know, but it works ok.
>
> -- CHS
>
>
> On 8/21/07, *Jim Lynch* <ale_nospam at fayettedigital.com
> <mailto:ale_nospam at fayettedigital.com>> wrote:
>
>     I want to flip flop two directories by pointing a soft link to one and
>     then the other the next day.  I'm trying to come up with the best
>     way to
>     tell which of the directories is linked so I can replace the link
>     with
>     the other one.
>
>     Something like
>
>     db1
>     db2
>     current -> db1
>
>     Then some sort of an if test that says
>
>     if current is linked to db1
>         ln -sf db2 current
>     else
>        ln -sf db1 current
>     fi
>
>     Any suggestions?
>
>     Thanks,
>     Jim.
>     _______________________________________________
>     Ale mailing list
>     Ale at ale.org <mailto:Ale at ale.org>
>     http://www.ale.org/mailman/listinfo/ale
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale




More information about the Ale mailing list