Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get specific section inside a MAN page?

Tags:

manual

I want to get only specific sections of MAN page inside a shell (or perl) script and print it.

For eg: only the SYNOPSIS section of MAN page

Is there any standard way to do that?

Regards, Anandan

like image 570
Anandan Avatar asked Jul 29 '09 17:07

Anandan


4 Answers

Not as far as I know, but you can search by typing '/' followed by the text you want to search for, then press 'n' repeatedly to go to the next match, or 'N' to go to the previous match.

like image 112
Cameron Avatar answered Oct 20 '22 22:10

Cameron


I haven't played with Linux/Unix in a long while, but perhaps you can perform a:

man MANPAGE|a2ps -m > grep -A 1000 SYNOPSIS
like image 38
David Glass Avatar answered Oct 20 '22 22:10

David Glass


Type the '/' key, then type the string you want to search for (you'll see your query at the bottom of the terminal as you type) and press enter. It'll highlight all the matches and take you to the first one. After that, type '/' and press enter to go to the next match.

like image 1
rob Avatar answered Oct 20 '22 23:10

rob


If you want to navigate to a specific section of a man page you can use this handy method:

Definition

man2() { 
  man -P 'less -p ^EXAMPLES' $1
} 

Example

man2 stat
like image 1
jasonleonhard Avatar answered Oct 20 '22 22:10

jasonleonhard