Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have seen -- used in the compgen command.

For example:

compgen -W "foo bar baz" -- b

What is the meaning of the --.

share|improve this question
add comment

2 Answers

up vote 66 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 "-v" like this:

grep -- -v file
share|improve this answer
1  
Most notably in the Bash set built-in, where it's absolutely necessary. –  l0b0 Oct 18 '12 at 9:03
    
-- 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
add comment

This marks end of parameter (option) list.

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

share|improve this answer
    
+1 for the link –  Ore4444 Nov 14 '13 at 14:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.