Shell – How to remove the directory a symbolic link links to plus the symbolic link

rmshellsymlink

Say a is a symbolic link to b. I am looking for a simple command to remove both a and b at once that does not require me to know about b.

Best Answer

Apparently I am not allowed to comment, so here as an answer: Since a is the link, we need the recursive option on the dereferenced directory...

rm -rf "$(readlink -f "a")"; rm -f "a"
Related Question