Subj : Re: help with bash prog and links To : comp.os.linux From : JV Date : Fri Sep 10 2004 03:55 am "Vilmos Soti" wrote in message news:87d60vjdkv.fsf@localhost.localdomain... > What do you try to accomplish? I'm trying to create a toggle that will change a link's target. > What is targ1? And what is ./lnk's relationship to targ1? > Also, what does softlink() do? It returns true if the argument is a symlink? targ1 = the first target targ2 = the other target > Are you trying to do something that ./lnk points to one target, > and you want to point it to the another one? Like a a toggle? yes > Anyways, to read the target of a symlink, use the "readlink" program. k thats what i needed > Here is a code (not tested) what might do what you want. > Vilmos k the code gave me the right idea to use thnx heres the finish code #!/bin/bash [ ! -L lnk ] && return if [ $(readlink lnk) == "./targ1/" ]; then rm lnk; ln -s ./targ1/ lnk; echo "DONE!!!"; echo "LNK => targ1/"; elif [ $(readlink lnk) == "./targ2/" ]; then rm lnk; ln -s ./targ2/ lnk; echo "DONE!!!" echo "LNK => targ2/"; fi Thanx for the help JV .