Delete directory by referencing symbolic link

Posted by Adam on Ask Ubuntu See other posts from Ask Ubuntu or by Adam
Published on 2013-10-31T16:11:17Z Indexed on 2013/10/31 16:16 UTC
Read the original article Hit count: 613

Filed under:
|
|
|

To set up the question, imagine this scenario:

    mkdir ~/temp
    cd ~/
    ln -s temp temporary

rm -rf temporary, rm -f temporary, and rm temporary each will remove the symbolic link but leave the directory ~/temp/.

I have a script where the name of the symbolic link is easily derived but the name of the linked directory is not.

Is there a way to remove the directory by referencing the symbolic link, short of parsing the name of the directory from ls -od ~/temporary?

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about scripts