This might be a really stupid question but I really haven't found an answer or even information that would help me with what I am trying to do. I just wanted to know if it is somehow possible to iterate over a man page's content with a python/shell etc. script (I want to have all possible parameters)? I saw that man pages are always gz-files. Is there a way to do this?
1 Answer
$man -P cat the-command-you-want | your-program
Or inside of your-program, call MYVAR=$(man -P cat the-command-you-want)
and operate on MYVAR.
The man pages more often than not contain MUCH more than just the parameter and options lists (likely more than you need or want). In that case, use B.Tanner's suggestion. Inside of your script: MYVAR=$(the-command-you-want --help)
.
From the man manpage:
Controlling formatted output
-P pager, --pager=pager Specify which output pager to use. By default, man uses less -s...
You are in this case using cat
instead of less
as the 'pager', so that you do not have to scroll through the manpage.
man command | script.py
), the question is what you want to do while iterating. Do you want to print some lines and skip others? Print only portions of lines? Which lines? Are you trying to extract only those lines that explain command line switches? Please edit your question and clarify. Ideally, add an example man page and the output you would want to see from it.