You could run the output of man
into the col
command and then pipe this to less
. Once in less
you can drop to a shell while still maintaining your location in less
.
$ man col | col -b | less
Once in less
you can use !bash
to get to a prompt to do what you want. When you're done you type exit
to return back to your location in less
.
Example
Here's a demo showing the whole operation.
Tell man to use a different pager
You can also tell man
to use different pagers via the -P
switch. So we could streamline the above method like so:
$ man -P less col
This is invoking man
and then outputting the contents of the page to less
, where again we can use !bash
to get to a shell. To return we use the same steps as above, exit
.
What's wrong with the default pager?
Actually nothing.
$ man col
It too can take the command !bash
to escape to a shell, where again we can type exit
to get back to the location where we were previously within the man page.
What else?
If you're feeling really crazy you can use vim
as an alternative pager too. Setting this up is a bit of a task but it's doable, directions for doing so are here in the vim wikia topic titled: Using vim as a man-page viewer under Unix.
Don't let the above page fool you, it doesn't just cover vim
methods. That topic covers dozens of ways you can change your man page pager in addition to using vim
.
You have not specified your desired output format but from the things you've tried, it looks like you're not picky. This will produce correctly formatted, unwrapped html but it needs to be run on the actual man page file.
So, first locate the man file you're interested in:
$ man -w mmap
/usr/share/man/man2/mmap.2.gz
Them, run man2html
on it:
man2html /usr/share/man/man2/mmap2.2.gz > mmap.html
Or, simply
zcat $(man -w mmap) | man2html > mmap.html
The output looks like this:
man2html
was available in the Debian repository, I installed it with sudo apt-get install man2html
.
Once you have it in HTML, you can translate to other formats easily enough: Actually, these won't work, they'll wrap the line automatically again.
man2html /usr/share/man/man1/grep.1.gz | html2ps > grep.ps
man2html /usr/share/man/man1/grep.1.gz | html2ps | ps2pdf14 - grep.man.pdf
`
Best Answer
First of all, the man files are usually just gziped text files somewhere in your file system. Since your milage will vary finding them and you probably wanted the processed and formatted version that man gives you instead of the source, you can just dump them with the
man
tool. By looking atman man
, I see that you can change the program used to view man pages with the-P
flag like this:It's also worth nothing that
man
automatically detects when you pipe it's output instead of viewing it on the screen, so if you are going to process it with something else you can skip straight to that step like so:or to dump TO a file: