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

后端 未结 4 1202
感情败类
感情败类 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 08:55

    You can get rid of it with:

    rm ./-s
    

    The rm command (at least under Ubuntu 10.04) even tells you such:

    pax@pax-desktop:~$ rm -w
    rm: invalid option -- 'w'
    Try `rm ./-w' to remove the file `-w'.
    Try `rm --help' for more information.
    

    The reason that works is because rm doesn't think it's an option (since it doesn't start with -) but it's still referring to the specific file in the current directory.

提交回复
热议问题