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

Clash Royale CLAN TAG#URR8PPP
up vote
372
down vote
favorite
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
add a comment |Â
up vote
372
down vote
favorite
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
add a comment |Â
up vote
372
down vote
favorite
up vote
372
down vote
favorite
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
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
shell command-line utilities
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
add a comment |Â
add a comment |Â
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
2
Most notably in the Bashsetbuilt-in, where it's absolutely necessary.
â l0b0
Oct 18 '12 at 9:03
7
--works to separate options from regular expressions ingrep, 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 asgrep -e -v file(although that is very confusing).
â Guss
Jan 21 '15 at 16:12
2
Not allbashbuiltin commands accept--as the end of option marker.[andechodon't for instance (one of the reasonsechocan't be used reliably).
â Stéphane Chazelas
Mar 21 '16 at 10:06
add a comment |Â
up vote
37
down vote
This marks end of parameter (option) list.
http://linux.about.com/library/cmd/blcmdl1_compgen.htm
add a comment |Â
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, andtestbuiltins do not accept options and do not treat--specially. Theexit,logout,break,continue,let, andshiftbuiltins 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
echodoes not interpret--to mean the end of options.
1
+1 for referencingman bash(note-to-self for next time : ).
â user3773048
Oct 18 at 21:24
add a comment |Â
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
add a comment |Â
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
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.
add a comment |Â
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
2
Most notably in the Bashsetbuilt-in, where it's absolutely necessary.
â l0b0
Oct 18 '12 at 9:03
7
--works to separate options from regular expressions ingrep, 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 asgrep -e -v file(although that is very confusing).
â Guss
Jan 21 '15 at 16:12
2
Not allbashbuiltin commands accept--as the end of option marker.[andechodon't for instance (one of the reasonsechocan't be used reliably).
â Stéphane Chazelas
Mar 21 '16 at 10:06
add a comment |Â
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
2
Most notably in the Bashsetbuilt-in, where it's absolutely necessary.
â l0b0
Oct 18 '12 at 9:03
7
--works to separate options from regular expressions ingrep, 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 asgrep -e -v file(although that is very confusing).
â Guss
Jan 21 '15 at 16:12
2
Not allbashbuiltin commands accept--as the end of option marker.[andechodon't for instance (one of the reasonsechocan't be used reliably).
â Stéphane Chazelas
Mar 21 '16 at 10:06
add a comment |Â
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
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
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 Bashsetbuilt-in, where it's absolutely necessary.
â l0b0
Oct 18 '12 at 9:03
7
--works to separate options from regular expressions ingrep, 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 asgrep -e -v file(although that is very confusing).
â Guss
Jan 21 '15 at 16:12
2
Not allbashbuiltin commands accept--as the end of option marker.[andechodon't for instance (one of the reasonsechocan't be used reliably).
â Stéphane Chazelas
Mar 21 '16 at 10:06
add a comment |Â
2
Most notably in the Bashsetbuilt-in, where it's absolutely necessary.
â l0b0
Oct 18 '12 at 9:03
7
--works to separate options from regular expressions ingrep, 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 asgrep -e -v file(although that is very confusing).
â Guss
Jan 21 '15 at 16:12
2
Not allbashbuiltin commands accept--as the end of option marker.[andechodon't for instance (one of the reasonsechocan'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
add a comment |Â
up vote
37
down vote
This marks end of parameter (option) list.
http://linux.about.com/library/cmd/blcmdl1_compgen.htm
add a comment |Â
up vote
37
down vote
This marks end of parameter (option) list.
http://linux.about.com/library/cmd/blcmdl1_compgen.htm
add a comment |Â
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
This marks end of parameter (option) list.
http://linux.about.com/library/cmd/blcmdl1_compgen.htm
answered Apr 15 '11 at 12:43
polemon
5,54464076
5,54464076
add a comment |Â
add a comment |Â
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, andtestbuiltins do not accept options and do not treat--specially. Theexit,logout,break,continue,let, andshiftbuiltins 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
echodoes not interpret--to mean the end of options.
1
+1 for referencingman bash(note-to-self for next time : ).
â user3773048
Oct 18 at 21:24
add a comment |Â
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, andtestbuiltins do not accept options and do not treat--specially. Theexit,logout,break,continue,let, andshiftbuiltins 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
echodoes not interpret--to mean the end of options.
1
+1 for referencingman bash(note-to-self for next time : ).
â user3773048
Oct 18 at 21:24
add a comment |Â
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, andtestbuiltins do not accept options and do not treat--specially. Theexit,logout,break,continue,let, andshiftbuiltins 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
echodoes not interpret--to mean the end of options.
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, andtestbuiltins do not accept options and do not treat--specially. Theexit,logout,break,continue,let, andshiftbuiltins 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
echodoes not interpret--to mean the end of options.
answered Mar 1 '15 at 14:36
kenorb
7,861365105
7,861365105
1
+1 for referencingman bash(note-to-self for next time : ).
â user3773048
Oct 18 at 21:24
add a comment |Â
1
+1 for referencingman 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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered Jun 30 at 14:29
John Doe
111
111
add a comment |Â
add a comment |Â
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
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.
add a comment |Â
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
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.
add a comment |Â
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
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
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.
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.
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password