As far as I remember, adding - as an option on the command line, will force the rm command to take into account all other arguments literally, therefore the command
rm -- -1
Remove funny named files. Note that you can still use shellextensions (for example, "*" or "?"), Since the shell expands them before running the command (unlike DOS).
Edit: When I first encountered this problem, I did not know about this switch, so I wrote a small c program that will remove the file name in the same way as the first argument. This is easy to do, since all posix operating systems contain a unlink system call that deletes the file with the name specified as an argument (dump in the following terminal):
remove_arg.c << EOF #include<unistd.h> int main(int argc, char **argv){ unlink(argv[1]); } EOF gcc -o remove_arg remove_arg.c ./remove_arg -1
This should work on any unix system, although you may need to change gcc to cc or what you called the local C compiler.
source share