End of Options

The options of UNIX® utilities usually are introduced with a dash (-) character.

This is problematic when a non-option argument has to be specified that begins with a dash. A common example for this are filenames.

Many utilities use the convention to specify two consecutive dashes (--) to signal "end of options at this point". Beyond this tag, no options are are processed anymore, even if an argument begins with a dash.

Example: You want to list (ls) the file with the name -hello. With common option processing, this could end up in the ls-options -h, -e, -l and -o and probably in an error message about invalid options. You use this to avoid the wrong option processing:

ls -- -hello

POSIX® specifies that every utility should follow this rule ("utility syntax guidelines"), except

  • echo (historical reasons)
  • test (obvious parsing reasons)
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • dict/terms/end_of_options.txt
  • Last modified: 2011/09/28 19:55
  • by thebonsai