0

I made a symlink to a directory like this:

ln -s /some/directory symlink

Now I'd like to remove the symlink:

rm symlink/

This doesn't work. The error message is:

rm: cannot remove 'symlink/': Is a directory

What am I doing wrong? Why does rm claim my symlink is a directory? How to remove the symlink properly?

Kamil Maciorowski
  • 19,242
  • 1
  • 50
  • 94
  • It's not that I haven't searched for possible duplicates. See [this meta answer](https://unix.meta.stackexchange.com/a/4444/108618). So disappointed by "search"… – Kamil Maciorowski Apr 11 '18 at 05:52

1 Answers1

6

There is this question: When should I use a trailing slash on a directory? and one of the answers says:

rm won't let you remove a symlink to a directory if there's a slash at the end

It's like you told rm the object is a directory.

rm symlink/   # wrong
rm symlink    # right
Kamil Maciorowski
  • 19,242
  • 1
  • 50
  • 94