How to search Linux man pages (e.g. with grep)

You have to tell grep that -X is not an option, but the pattern to look for:

man curl | grep -- '-X'

-- indicates the end of options. Without it, grep thinks that -X is an option.

Alternatively, you can use -e to indicate that what follows is a pattern:

man curl | grep -e '-X'

If you want to see the complete man page but skip directly to the first occurrence of -X, you can use a command line option to less:

man curl | less +/-X

Typing N repeatedly then takes you to the following occurrences.


On most Linux systems, the default pager used by man is less.

If that is the case, you can search in a manpage using the / (slash) key followed by a query (here -X) and finally hit ENTER. It will highlight all cases of -X. It is of course possible that the first "hit" is not the one you want. In that case you can hit N to go to the Next hit and so browse through the entire document. In case you have jumped too far, you can use Shift+N to jump back to the previous hit.

This is not really an answer to the question how to handle this with grep, but it is simply a way to efficiently search in man.

You can read the manpage of less (man less) for further tricks on how to effectively use less to improve your experience with manpages.