I don't know how this happened, but I have a broken symlink in my home directory named *. I was just about to rm *, and then I had a facepalm moment. Should I rm \*? rm '*'? Something else? Backing up now...

  • @slhck A broken symlink is not a directory. You do not generally remove directories and files the same way. Here the '*' file is not under the file system root. There are more than one question in Dan Ross' one. Bottom line: I would not close that question. – jlliagre May 22 '13 at 18:04
  • @jlliagre The questions are not the same, but the answers are, and they boil down to escaping the glob, or quoting it, so anybody looking to remove such a file should find the answers helpful. – slhck May 22 '13 at 18:23
  • @slhck I agree there are many similarities and the other answers would have been helpful but they do not suggest using -i which I guess is the reason why I quickly got upvotes. – jlliagre May 22 '13 at 19:45

Both rm \* and rm '*' would be fine, rm "*" too.

When in doubt, you should use the -i option for rm to prompt you before removing a file. For example this command will remove all files which name has only one character but only if you accept it:

rm -i ?
| improve this answer | |
  • Thank you, this is not the sort of thing I like to experiment with. If I screwed up and had to restore from a backup, then the timestamps on all my files would be reset. Not the end of the world, but certainly not cool. Accepting in 49 seconds... – Dan Ross May 22 '13 at 5:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.