Delete a file whose name begins with a dash

When using a unix terminal, sometimes you make typos and end up creating files starting with a dash "-"

For example, instead of typing

$touch ./h-ello.txt

if you ended up typing

$touch ./-hello.txt

this would create a file named -hello.txt

Trying to delete a file with a name starting with a dash will cause an error in the bash shell:

$rm -hello.txt
rm: invalid option -- h
Try `rm --help' for more information.

To get around the dash in the filename, use a double-dash "--" before the rm arguments to delete the file starting with a dash.

$rm -- -hello.txt