I have this file in my linux machine:
----------9976723563nneh4_-----192.9.200.4
I try to delete this file but I cant as all see here:
what need to add to rm in order to remove this file ?
rm "----------9976723563nneh4_-----192.9.200.4"
rm: illegal option -- --------9976723563nneh4_-----192.9.200.4
usage: rm [-fiRr] file ...
.
rm '----------9976723563nneh4_-----192.9.200.4'
rm: illegal option -- --------9976723563nneh4_-----192.9.200.4
usage: rm [-fiRr] file ...
You need
--
in order to tellrm
(and more or less all other GNU software) that all following parameters are file names even when beginning with "-". Otherwise (and in your case) the file name is confused with options. Another possibility isEdit 1
Calling this trivial answer a "great solution" makes me feel obliged to take it to a higher level. The basic problem cannot be solved "better" but you can try to get used to always making
--
an argument. And some shell code (replacing rm by a shell function) can help you with this:You would put this in e.g.
~/.bashrc
.From the manual page for
rm
:so to remove your file, try
rm -- ----------9976723563nneh4_-----192.9.200.4
.