TIL - Remove (rm) Filename Starting by Dash

October 14, 2024  |  1 min read

To delete files with names started by dash (-), use option -- followed by filenames to stop rm from processing flags beyond it:

$ rm -some-file
# rm: illegal option -- s
 
$ rm -- -some-file
$ rm -r -- --some-dir

Refs