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.
fgrep --help | fgrep "--help"

returns just the whole fgrep --help, how do I return just the lines that have the literal "--help" in them?

The quotes don't do anything, nor does \-\-help.

share|improve this question
    
I meant \-\-help –  lonewarrior556 Aug 5 at 18:49
3  
fgrep -- --help –  Ulrich Dangel Aug 5 at 18:51
    
Yes! does fgrep -- take every argument literally? –  lonewarrior556 Aug 5 at 18:55
4  
@lonewarrior556 Escaping the hyphen with a backslash is useless because you want the protection for the command (fgrep), not for the shell. –  vinc17 Aug 5 at 18:58

2 Answers 2

up vote 9 down vote accepted

I believe you can use

fgrep -- --help

to achieve this. The man page mentions

fgrep -e --help

Quote from http://www.openbsd.org/cgi-bin/man.cgi?query=grep:

-e pattern Specify a pattern used during the search of the input: an input line is selected if it matches any of the specified patterns. This option is most useful when multiple -e options are used to specify multiple patterns, or when a pattern begins with a dash (‘-’).

share|improve this answer

Alternate solution: use the -e option, as suggested by the man page ("to protect a pattern beginning with a hyphen"):

fgrep -e --help
share|improve this answer

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.