Some program makes ta my root directory dummy files such as
-1
-2
-3
...
-n
I run unsuccessfully
rm -1
and too
rm "-1"
Terminal thinks that -1 is the option.
How can you remove the files in terminal?
Some program makes ta my root directory dummy files such as
-1
-2
-3
...
-n
I run unsuccessfully
rm -1
and too
rm "-1"
Terminal thinks that -1 is the option.
How can you remove the files in terminal?
You can use
rm ./-1
, the ./ refers to the current directory and as the parameter doesn't start with a dash it isn't interpreted as an option.As far as I recall adding -- as an option on the commandline will cause the rm command to consider all the remaining arguments literally, so the command
Will remove the funny named files. Note that you can still use shellextensions (such as '*' or '?') since the shell expand these before the command is run (unlike DOS).
Edit: When I was first faced with this problem, I didn't know about the -- switch so I wrote a small c program that would remove the file name the same as the first argument. This is easy to do since all posix operating systems contain the
unlink
system call which removes the file with the name given as argument (dump the following into a terminal):This should work on any unix system, although you may have to change
gcc
intocc
or what you local c compiler is named.