I'm looking for information on the -X
option of curl
. However, the documentation is quite lengthy and I have to scroll down for quite a long time to get to this option. Instead, I'd like to do something like
man curl | grep -X
to get the line containing "-X". (I would also do this in conjunction with the option -A 10
to get the 10 lines after the match). However, if I try this I get
grep: option requires an argument -- 'X'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Any ideas on how to use grep
together with man
, or more generally on how to search man pages for specific lines?
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.