Read a File Beginning with a Dash

A file named -, --help, or -rf is legal on UNIX filesystems, but most command-line tools parse leading dashes as option switches. cat - reads from stdin, not a file called -. rm -rf is worse.

The fix

Prefix the filename with a path so it no longer begins with a dash:

cat ./-          # reads a file literally named `-`
cat ./--help     # reads a file literally named `--help`

Alternatively, use -- to signal the end of options:

cat -- -
rm -- -rf

Why this matters for security

  • Exploit mitigation: Wildcard abuse often plants files named like options. Using -- or absolute paths in scripts neutralizes that entire class of attack.
  • Post-exploitation: Attackers sometimes name loot or tools with leading dashes to make them awkward for defenders to handle. Knowing how to read them is a basic DFIR skill — see xxd for inspecting binary contents of such files once you can open them.

Sources