26

Recently I got to know of -- that is double-hyphen which is used to tell a command that the option list has ended and what follows should not be considered as a option. So,

grep --  'search_word' *

would search for the given search_word. But you could see a unexpected behavior if you remove -- and if there is a single file that start with -, which would switch on the option that match with the chars in filename.

What is this -- called ? Is there any technical term to this ?

mtk
  • 27,530
  • 35
  • 94
  • 130

2 Answers2

18

The -- is working for tools which use getopt(3) to process command line arguments and many API that parse POSIX style options.

From the manual page of getopt(3):

The interpretation of options in the argument list may be cancelled by the option `--' (double dash) which causes getopt() to signal the end of argument processing and return -1.

I would then say it is called double dash

Matteo
  • 9,796
  • 4
  • 51
  • 66
5

The only two names which I've head in practise are "double dash" for referring to it aesthetically, and "end of options" for referring to it functionally.

Chris Down
  • 125,559
  • 25
  • 270
  • 266