What does “--” (double-dash) mean? (also known as “bare double dash”)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
372
down vote

favorite
134












I have seen -- used in the compgen command.



For example:



compgen -W "foo bar baz" -- b


What is the meaning of the -- in there?










share|improve this question



























    up vote
    372
    down vote

    favorite
    134












    I have seen -- used in the compgen command.



    For example:



    compgen -W "foo bar baz" -- b


    What is the meaning of the -- in there?










    share|improve this question

























      up vote
      372
      down vote

      favorite
      134









      up vote
      372
      down vote

      favorite
      134






      134





      I have seen -- used in the compgen command.



      For example:



      compgen -W "foo bar baz" -- b


      What is the meaning of the -- in there?










      share|improve this question















      I have seen -- used in the compgen command.



      For example:



      compgen -W "foo bar baz" -- b


      What is the meaning of the -- in there?







      shell command-line utilities






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 14 '17 at 20:04









      Jeff Schaller

      34.5k951115




      34.5k951115










      asked Apr 15 '11 at 12:39









      dogbane

      13.7k96358




      13.7k96358




















          5 Answers
          5






          active

          oldest

          votes

















          up vote
          452
          down vote



          accepted










          More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted.



          Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with -- you can grep for string -v like this:



          grep -- -v file





          share|improve this answer


















          • 2




            Most notably in the Bash set built-in, where it's absolutely necessary.
            – l0b0
            Oct 18 '12 at 9:03






          • 7




            -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
            – l0b0
            Oct 18 '12 at 9:05






          • 4




            @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
            – Guss
            Jan 21 '15 at 16:12






          • 2




            Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
            – Stéphane Chazelas
            Mar 21 '16 at 10:06

















          up vote
          37
          down vote













          This marks end of parameter (option) list.



          http://linux.about.com/library/cmd/blcmdl1_compgen.htm






          share|improve this answer



























            up vote
            28
            down vote













            In man bash we can read in Shell Builtin Commands section:




            Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.



            The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.



            Note that echo does not interpret -- to mean the end of options.







            share|improve this answer
















            • 1




              +1 for referencing man bash (note-to-self for next time : ).
              – user3773048
              Oct 18 at 21:24

















            up vote
            1
            down vote














            POSIX.1-2017



            12.2 Utility Syntax Guidelines



            Guideline 10:



            The first -- argument that is not an option-argument should be
            accepted as a delimiter indicating the end of options. Any following
            arguments should be treated as operands, even if they begin with the
            '-' character.




            http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02






            share|improve this answer



























              up vote
              -1
              down vote













              Please read manual of bash. Here is the link.
              https://www.gnu.org/software/bash/manual/bash.html#Shell-Builtin-Commands





              share








              New contributor




              shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

















                Your Answer







                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f11376%2fwhat-does-double-dash-mean-also-known-as-bare-double-dash%23new-answer', 'question_page');

                );

                Post as a guest






























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                452
                down vote



                accepted










                More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted.



                Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with -- you can grep for string -v like this:



                grep -- -v file





                share|improve this answer


















                • 2




                  Most notably in the Bash set built-in, where it's absolutely necessary.
                  – l0b0
                  Oct 18 '12 at 9:03






                • 7




                  -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                  – l0b0
                  Oct 18 '12 at 9:05






                • 4




                  @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                  – Guss
                  Jan 21 '15 at 16:12






                • 2




                  Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                  – Stéphane Chazelas
                  Mar 21 '16 at 10:06














                up vote
                452
                down vote



                accepted










                More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted.



                Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with -- you can grep for string -v like this:



                grep -- -v file





                share|improve this answer


















                • 2




                  Most notably in the Bash set built-in, where it's absolutely necessary.
                  – l0b0
                  Oct 18 '12 at 9:03






                • 7




                  -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                  – l0b0
                  Oct 18 '12 at 9:05






                • 4




                  @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                  – Guss
                  Jan 21 '15 at 16:12






                • 2




                  Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                  – Stéphane Chazelas
                  Mar 21 '16 at 10:06












                up vote
                452
                down vote



                accepted







                up vote
                452
                down vote



                accepted






                More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted.



                Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with -- you can grep for string -v like this:



                grep -- -v file





                share|improve this answer














                More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted.



                Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with -- you can grep for string -v like this:



                grep -- -v file






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 21 '16 at 9:49









                cuonglm

                99.7k23194292




                99.7k23194292










                answered Apr 15 '11 at 13:13









                Guss

                5,81111224




                5,81111224







                • 2




                  Most notably in the Bash set built-in, where it's absolutely necessary.
                  – l0b0
                  Oct 18 '12 at 9:03






                • 7




                  -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                  – l0b0
                  Oct 18 '12 at 9:05






                • 4




                  @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                  – Guss
                  Jan 21 '15 at 16:12






                • 2




                  Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                  – Stéphane Chazelas
                  Mar 21 '16 at 10:06












                • 2




                  Most notably in the Bash set built-in, where it's absolutely necessary.
                  – l0b0
                  Oct 18 '12 at 9:03






                • 7




                  -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                  – l0b0
                  Oct 18 '12 at 9:05






                • 4




                  @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                  – Guss
                  Jan 21 '15 at 16:12






                • 2




                  Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                  – Stéphane Chazelas
                  Mar 21 '16 at 10:06







                2




                2




                Most notably in the Bash set built-in, where it's absolutely necessary.
                – l0b0
                Oct 18 '12 at 9:03




                Most notably in the Bash set built-in, where it's absolutely necessary.
                – l0b0
                Oct 18 '12 at 9:03




                7




                7




                -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                – l0b0
                Oct 18 '12 at 9:05




                -- works to separate options from regular expressions in grep, but the canonical way is to use -e/--regexp.
                – l0b0
                Oct 18 '12 at 9:05




                4




                4




                @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                – Guss
                Jan 21 '15 at 16:12




                @l0b0: the pattern to search is normally one of the positional parameters, so it can fit after the --, though you are correct in noting that my example above could also be written as grep -e -v file (although that is very confusing).
                – Guss
                Jan 21 '15 at 16:12




                2




                2




                Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                – Stéphane Chazelas
                Mar 21 '16 at 10:06




                Not all bash builtin commands accept -- as the end of option marker. [ and echo don't for instance (one of the reasons echo can't be used reliably).
                – Stéphane Chazelas
                Mar 21 '16 at 10:06












                up vote
                37
                down vote













                This marks end of parameter (option) list.



                http://linux.about.com/library/cmd/blcmdl1_compgen.htm






                share|improve this answer
























                  up vote
                  37
                  down vote













                  This marks end of parameter (option) list.



                  http://linux.about.com/library/cmd/blcmdl1_compgen.htm






                  share|improve this answer






















                    up vote
                    37
                    down vote










                    up vote
                    37
                    down vote









                    This marks end of parameter (option) list.



                    http://linux.about.com/library/cmd/blcmdl1_compgen.htm






                    share|improve this answer












                    This marks end of parameter (option) list.



                    http://linux.about.com/library/cmd/blcmdl1_compgen.htm







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 15 '11 at 12:43









                    polemon

                    5,54464076




                    5,54464076




















                        up vote
                        28
                        down vote













                        In man bash we can read in Shell Builtin Commands section:




                        Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.



                        The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.



                        Note that echo does not interpret -- to mean the end of options.







                        share|improve this answer
















                        • 1




                          +1 for referencing man bash (note-to-self for next time : ).
                          – user3773048
                          Oct 18 at 21:24














                        up vote
                        28
                        down vote













                        In man bash we can read in Shell Builtin Commands section:




                        Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.



                        The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.



                        Note that echo does not interpret -- to mean the end of options.







                        share|improve this answer
















                        • 1




                          +1 for referencing man bash (note-to-self for next time : ).
                          – user3773048
                          Oct 18 at 21:24












                        up vote
                        28
                        down vote










                        up vote
                        28
                        down vote









                        In man bash we can read in Shell Builtin Commands section:




                        Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.



                        The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.



                        Note that echo does not interpret -- to mean the end of options.







                        share|improve this answer












                        In man bash we can read in Shell Builtin Commands section:




                        Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.



                        The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.



                        Note that echo does not interpret -- to mean the end of options.








                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 1 '15 at 14:36









                        kenorb

                        7,861365105




                        7,861365105







                        • 1




                          +1 for referencing man bash (note-to-self for next time : ).
                          – user3773048
                          Oct 18 at 21:24












                        • 1




                          +1 for referencing man bash (note-to-self for next time : ).
                          – user3773048
                          Oct 18 at 21:24







                        1




                        1




                        +1 for referencing man bash (note-to-self for next time : ).
                        – user3773048
                        Oct 18 at 21:24




                        +1 for referencing man bash (note-to-self for next time : ).
                        – user3773048
                        Oct 18 at 21:24










                        up vote
                        1
                        down vote














                        POSIX.1-2017



                        12.2 Utility Syntax Guidelines



                        Guideline 10:



                        The first -- argument that is not an option-argument should be
                        accepted as a delimiter indicating the end of options. Any following
                        arguments should be treated as operands, even if they begin with the
                        '-' character.




                        http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02






                        share|improve this answer
























                          up vote
                          1
                          down vote














                          POSIX.1-2017



                          12.2 Utility Syntax Guidelines



                          Guideline 10:



                          The first -- argument that is not an option-argument should be
                          accepted as a delimiter indicating the end of options. Any following
                          arguments should be treated as operands, even if they begin with the
                          '-' character.




                          http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02






                          share|improve this answer






















                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote










                            POSIX.1-2017



                            12.2 Utility Syntax Guidelines



                            Guideline 10:



                            The first -- argument that is not an option-argument should be
                            accepted as a delimiter indicating the end of options. Any following
                            arguments should be treated as operands, even if they begin with the
                            '-' character.




                            http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02






                            share|improve this answer













                            POSIX.1-2017



                            12.2 Utility Syntax Guidelines



                            Guideline 10:



                            The first -- argument that is not an option-argument should be
                            accepted as a delimiter indicating the end of options. Any following
                            arguments should be treated as operands, even if they begin with the
                            '-' character.




                            http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 30 at 14:29









                            John Doe

                            111




                            111




















                                up vote
                                -1
                                down vote













                                Please read manual of bash. Here is the link.
                                https://www.gnu.org/software/bash/manual/bash.html#Shell-Builtin-Commands





                                share








                                New contributor




                                shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.





















                                  up vote
                                  -1
                                  down vote













                                  Please read manual of bash. Here is the link.
                                  https://www.gnu.org/software/bash/manual/bash.html#Shell-Builtin-Commands





                                  share








                                  New contributor




                                  shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.



















                                    up vote
                                    -1
                                    down vote










                                    up vote
                                    -1
                                    down vote









                                    Please read manual of bash. Here is the link.
                                    https://www.gnu.org/software/bash/manual/bash.html#Shell-Builtin-Commands





                                    share








                                    New contributor




                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    Please read manual of bash. Here is the link.
                                    https://www.gnu.org/software/bash/manual/bash.html#Shell-Builtin-Commands






                                    share








                                    New contributor




                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.








                                    share


                                    share






                                    New contributor




                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    answered 7 mins ago









                                    shuaihanhungry

                                    1




                                    1




                                    New contributor




                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





                                    New contributor





                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    shuaihanhungry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f11376%2fwhat-does-double-dash-mean-also-known-as-bare-double-dash%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Displaying single band from multi-band raster using QGIS

                                        How many registers does an x86_64 CPU actually have?