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

Charles Shapiro hooterpincher at gmail.com
Tue Aug 21 11:05:52 EDT 2007


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> 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
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list