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
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.
You can refer to it either using ./-filename
or some command will allow you to put it after double dash:
rm -- -filename
You could use --, e.g.:
rm -- -file
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")'