How to dump a man page?

To get an ASCII man page file, without the annoying backspace/underscore attempts at underlining, and weird sequences to do bolding:

man ksh | col -b > ksh.txt

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 at man man, I see that you can change the program used to view man pages with the -P flag like this:

man -P cat command_name

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:

man command_name | grep search_string

or to dump TO a file:

man command_name > formatted_man_page.txt

Man pages are usually troff pre-processed files, and you can get to the plain text with,

groff -t -e -mandoc -Tascii manpage.1 | col -bx > manpage.txt

groff is a wrapper for troff.

More information here.

You might need to use gzip to uncompress the man page files first, and you'll still have plenty of formatting information in the output.

Tags:

Man