GAURAVGUPTA9
10th August 2002, 10:04
Hi all
in unix i have got a serious problam. there is a file named -0 of size 850 MB. and i want to remove this file. and this file is not getting removed. i am using rm -0(this is file name).
wot to do. reply soon.
Regds
Gaurav
patvdv
10th August 2002, 11:08
Try putting the file name between single quotes:
rm '-0'
Another option you have is to move all other files out of that directory, then remove that directory including the file, recreate the directory and move the other files back.
patvdv
10th August 2002, 11:22
I remembered correctly by thinking this is a question that comes up in the official UNIX FAQ (http://www.faqs.org/faqs/unix-faq/faq/):
2.1) How do I remove a file whose name begins with a "-" ?
Figure out some way to name the file so that it doesn't begin
with a dash. The simplest answer is to use
rm ./-filename
(assuming "-filename" is in the current directory, of course.)
This method of avoiding the interpretation of the "-" works with
other commands too.
Many commands, particularly those that have been written to use
the "getopt(3)" argument parsing routine, accept a "--" argument
which means "this is the last option, anything after this is not
an option", so your version of rm might handle "rm -- -filename".
Some versions of rm that don't use getopt() treat a single "-"
in the same way, so you can also try "rm - -filename".