How do I deal with a filename that starts with the hyphen (-) character?

后端 未结 4 1208
感情败类
感情败类 2020-11-28 08:34

Somehow, at some point, I accidentally created a file in my home directory named \'-s\'. It is about 500 kb and I have no idea if it contains important data or not. I cannot

4条回答
  •  天涯浪人
    2020-11-28 09:18

    besides using rm, if you know a language, you can also use them. They are not affected by such shell warts.

    Ruby(1.9+)

    $ ruby -rfileutils -e 'FileUtils.rm("-s")'
    

    or

    $ ruby -e 'File.unlink("-s")'
    

提交回复
热议问题