How would you create and then delete a file that begins with the symbol "-"? Try it.
I can't write the command for this question and I don't why.
How would you create and then delete a file that begins with the symbol "-"? Try it.
I can't write the command for this question and I don't why.
touch -- <filename>
rm -- <filename>
--
ends the command line switches.
Or, without using the GNU -- convention, you can use ./:
Thus touch ./-filename
and rm ./-filename
You can use --
switch. For example rm -- -test
will delete -test
file.
You can also use a path of the file. For example rm ./-test
will delete -test
file.
The above are much easier, and you should use the './' trick (it would work on MacOSX or BSD for example), but for completeness:
Use ls -i
to get the inode number, and then use find . -inum INODENUMBER -delete -print