1

I accidentally created a file named '. Is there a simple way to delete this in bash? Unfortunately, there is already default behavior for rm '.

  • 1
    can you post the command that created it? that could also give a clue to delete it – Sundeep Oct 25 '16 at 16:14
  • vim "'" was the command i used – heliotrope Oct 25 '16 at 16:30
  • 1
    so rm "'" would have worked too ;) – Sundeep Oct 25 '16 at 16:31
  • 1
    If you want to delete your question, you can do so yourself. You should see a "delete" button under it. However, please don't let a couple of downvotes get you down. We've all done silly things and we were all newbs before becoming experts. I think the downvoters didn't realize just how hard it is to search for special characters on search engines. – terdon Oct 25 '16 at 16:52
5

Using double quotes around ':

rm "'"

Using single quote, and escaping:

rm \' 
  • rm \' also works – Joseph R. Oct 25 '16 at 16:13
  • @JosephR. Actually was in the middle of incorporating this :) – heemayl Oct 25 '16 at 16:15
  • 1
    ...and in the general case rm -i ? could help, since ? is a wildcard representing any a single character – roaima Oct 25 '16 at 18:53
  • Just to have some other option: rm $'\'' also works. ;-) – sorontar Oct 26 '16 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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