How to read a local manpage file?

We all know the famous expression RTFM. The man command is our best friend. Smiling But what to do if you've just downloaded something and want to read a manpage that was bundled within? Here's the command to use:
groff -t -e -mandoc -Tascii filename | less

The output of that groff command is still not pure ASCII. It contains escape sequences for marking bold and italic text. However it's only a good thing if you're piping the output into less since the latter is capable of interpreting those escapes and can show you bold/italic/etc. texts.

However if you really want to have an ascii version of the manpage (eg. to save it into a text file), you can remove the escapes with col:
groff -t -e -mandoc -Tascii filename | col -b > filename.txt

The above groff commands produce pretty much the same output that you get by invoking the man command. This means that you can save the rendered output of an installed manpage into a text file using col too:
man sometopic | col -b > sometopic.txt

Update (2010.06.24): it seems somebody realized the usefulness of a "wrapper" around groff that would make reading manpage files easier. Today in most distributions you can use the following syntax:
nroff -man filename
(and pipe the output into col -b if you want a pure ascii output)

Syndicate content