If you want to grep for a pattern beginning with a hyphen, use --
before the pattern you specify.
man find | grep -- -type
If you want more info, for example the entire section describing an option, you could try using Sed:
$ man find | sed -n '/-mindepth/,/^$/p'
-mindepth levels
Do not apply any tests or actions at levels less than levels (a
non-negative integer). -mindepth 1 means process all files
except the command line arguments.
However, this won't work for every option you might search for. For example:
$ man find | sed -n '/^[[:space:]]*-type/,/^$/p'
-type c
File is of type c:
Not very helpful. Worse, for some options you could be misled into thinking you'd read the whole text about the option when you really hadn't. For example, searching -delete
omits the very important WARNING contained as a second paragraph under that heading.
My recommendation is to use a standard call to man
with the LESS
environment variable set. I use it quite commonly in my answers on this site.
LESS='+/^[[:space:]]*-type' man find
To learn more about how this works, see:
LESS='+/^[[:space:]]*LESS ' man less
LESS='+/\+cmd' man less
LESS='+/\/' man less
If you just want to find the option quickly and interactively in the man page, learn to use less
's search capabilities. And also see:
-type
, or do you want, say, the entire paragraph or two that describes what-type
does?-type
would be enough for the way I usually search the man pages, however returning the entire paragraph or two that describes what-type
does would be very useful to do at least one time.-type
option does.