2

I want to jump straight to the description of an option of a command. Something like man ls -la or gcc -g or cat -n etc. you get it. Is there a way to do that?

1 Answer 1

5

What I typically do is in a man page hit /, and then type something to search.

Or if you want to jump directly to a section you could use man --pager. For example, if you wanted to go to the section about -h of ls you could do man --pager='less -p -h' ls. This could easily be made into a little bash script if you want to use this all the time.

If you want to jump directly to a section, and avoid hangups add 4 spaces in front of the section like so, man --pager='less -p " -h"' ls.

6
  • the problem with this that it jumps to the first occurrence of the parameter not to the description. Eg. if there is a short description of the often used options in the head of the man page, then it shows that.
    – godzsa
    Commented May 4, 2016 at 19:18
  • Well, you'll have to make your search more specific. So, I see that if I do man --pager='less -p -l' ls it hits the --author section which references -l. To make it more specific adding a tab to the front of the search will go directly to the description, like this man --pager='less -p " -l"' ls. Seeing as all description subsections have tabs in front of them, this could be scripted for your desired effect. I'll add an example in my main post.
    – vesche
    Commented May 4, 2016 at 19:30
  • Sure but this is not exactly what I am looking for. Maybe there is no way to do that. I am trying to make your solution work with gcc -g but it won't work
    – godzsa
    Commented May 4, 2016 at 19:37
  • ... I can't figure out how to do multiple spaces in markdown in the comments, but pretend there is 4 spaces before the -l in that last command in my previous comment.
    – vesche
    Commented May 4, 2016 at 19:37
  • The syntax provided will allow you to jump straight to the description of a command which is exactly what you said you were looking for. You can easily clean this up by adding it into a bash script like man --pager='less -p $2' $1 call it something like manjump, and then call it with manjump ls -l and it will be pretty smooth.
    – vesche
    Commented May 4, 2016 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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