Monday, May 13, 2013

Removing a file/directory that starts with a "-" in Linux/Unix

Removing a file/directory that starts with the character "-" can be tricky in Linux/Unix. On Linux/Unix you may get this error when attempting to remove a file/directory:
rm: invalid option -- '1'

Some commands may give you a hint e.g.
Try `rm ./-1' to remove the file `-1'.

This is exactly what is required i.e just append the "./" to the file/folder to resolve your problem.

No comments:

Post a Comment