3

Whenever I search the manpages, I'm almost always trying to find out what's going on with a specific flag. For example, when searching the man pages for pandoc I was searching the for -f flag. I'm not sure how to say, quickly get to the flag which is here:

OPTIONS
   General options
       -f FORMAT, -r FORMAT, --from=FORMAT, --read=FORMAT

and filter out stuff like:

iconv -t utf-8 input.txt | pandoc | iconv -f utf-8           

or

pandoc -f markdown -t latex hello.txt

I've tried searching for /-f, and I've looked at another post and tried (^|\s)-f($|\s\) but it was invalid. So I'm wondering how do you quickly search less for "only the flag -f"?

Would love your thoughts or some other tool that you use to quickly go through documentation

  • 1
    first, good for you for using the man pages! i'd humbly suggest starting with looking for an OPTIONS section (forward slash to activate search then type uppercase: OPTIONS). in your search for -f be sure to include a space after it (without quotes): '-f ', finally try the command itself with an '-h', and perhaps pipe to grep: pandoc -h | grep -A 3 '\-f ' – Theophrastus Oct 22 '16 at 18:23
  • thanks for the suggestion! Searching for 'OPTIONS' then -f with the space helps, but then I tried reading the reading the man pages for grep to figure out what -A was and missed it because grep uses DESCRIPTION to put it's flags instead of OPTIONS ;). Is there any rhyme or reason for when a command uses one or the other? Also I like piping the help into grep, I'm going to mess around with it more, and maybe make a script out of it, would love your feedback when I do – mbigras Oct 22 '16 at 19:02
1

One reasonably convenient, if not perfect, approach is to rely on the fact that the definition of an option usually involves that option being at the start of a line preceded only by spaces, so you can type:

/^ *-f

If you want to search for a long option, you might find that there's a short option before it, so you could type this instead:

/^ *-.*-from

While it may be possible to get a bit more accurate than this, for interactive use you normally want something quick and easy to remember.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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