I can't tell if you want some "special" formatting that's different from standard formatting that's done using ANSI escape codes:
I'd prefer the output to have proper formatting, line bolding,
underscores, fixed-width font for examples etc.
(does "proper just mean "the normal way that man
does it"?)
But... I will answer with regards to this part of your question:
How can I get contents of a man page without the text being wrapped
around column 80 or so?
Just use:
MANWIDTH=9999 man mmap > mmap.txt
or:
COLUMNS=9999 man mmap > mmap.txt
If you need to do something fancier, you can use groff
directly, but it doesn't seem to respect the COLUMNS
variable. This awesome answer provided a solution: use the arguments -rLL <number>
and -rLT <number>
to groff
(apparently undocumented, but man
itself uses them).
For example, I use the following function to dump man
pages to plain-text (intentionally disabling the formatting that you want to preserve, but just as an example):
man2txt() {
groff -t -e -mandoc -Tascii -a -rLL=9999 -rLT=9999 "$(man -w "${1}")"
}
You could remove the -Tascii -a
and add in whatever groff
options you want, if you do in fact want to do anything special in that regard.
man -P cat command_name
. – slm Jan 30 '14 at 05:34man -P cat
won't do it and neither will any of the other answers on the linked Q. – terdon Jan 30 '14 at 05:42man -P less command_name
. Is this not what you want? – slm Jan 30 '14 at 05:43man
look better when you run it on a large screen? – Mikel Jan 30 '14 at 05:51/usr/share/man/man2/mmap.2.gz
, you'll notice there's not a lot of markup to help tell what's English prose, and what's a code sample. How would you tell the difference? – Mikel Jan 30 '14 at 06:14man2html
definitely distinguish English prose from source code in "EXAMPLE" section and renders it the correct way. Maybe th.nf
markup? – mbaitoff Jan 30 '14 at 06:43man2html
formats it flawlessly while on the other one it has issues with code sample (single line breaks are not interpreted verbatim). – peterph Jan 30 '14 at 11:25man2html
output? It's soft wrapped, but that doesn't matter in HTML: only tags such as<p>
and<br>
cause actual line breaks. – Mikel Feb 02 '14 at 20:23man2html
is the most appropriate solution to my question, and I marked the corresponding answer as accepted. – mbaitoff Feb 03 '14 at 05:45