Solved: How to remove a symbolic link to a directory

Post Reply
mister_v
Posts: 139
Joined: Sat Jun 20, 2009 5:42 pm

Solved: How to remove a symbolic link to a directory

Post by mister_v »

Hi,

I want to delete a symbolic link to a directory
Put it doesn't work with rm

Code: Select all

rm DIR/
rm: cannot remove 'DIR/': Is a directory
Even forcing it:

Code: Select all

rm -f DIR/
rm: cannot remove 'DIR/': Is a directory
I don't want to do rm -fr,
because it might delete everything in the directory,
and I don't want that.

Even tried "unlink"

Code: Select all

unlink DIR/
unlink: cannot unlink 'DIR/': Not a directory
Doesn't work either
Last edited by mister_v on Fri Jul 19, 2013 5:53 pm, edited 1 time in total.
Chris
Site Admin
Posts: 129
Joined: Mon Jul 21, 2008 9:45 am
Location: Leuven, Belgium
Contact:

Re: How to remove a symbolic link to a directory

Post by Chris »

You need to handle it like a file.
Without the slash '/'

Code: Select all

rm DIR
This should work.

When you use tab to complete the directory-name,
it automatically adds the slash (/).
But it is not needed in this case.
mister_v
Posts: 139
Joined: Sat Jun 20, 2009 5:42 pm

Re: How to remove a symbolic link to a directory

Post by mister_v »

Ok this was the problem.

I feel kinda stupid now.
Post Reply