Home / Journal

Print man Pages to Text File

Print man Pages to Text File

If you need to save a copy of a man (manual) page for a specific command — to read offline, search through, or print — type the following on your command shell:

man [command] | col -b > filename.txt

Replace [command] with the command of your choice, and you'll get its manual written to filename.txt.

Why col -b?

To show bold and underline, man pages use overstrike sequences — a character, a backspace, then the same character again. When that formatting reaches a file it shows up as junk like l^Hls^Hs scattered through the text, and col -b strips those backspaces to leave clean, readable output.

That said, modern versions of man detect when their output isn't going to a terminal and often emit plain text on their own — so on an up-to-date Linux box, man ls > ls.txt may already come out clean. Behavior still varies across systems (older distros, the BSDs, macOS), so piping through col -b is the portable habit that guarantees a clean file everywhere.

A quick example

Say you want the manual for ls:

man ls | col -b > ls.txt

Now ls.txt is a tidy plain-text copy you can open in any editor, grep through, or email to yourself.

Bonus: save it as a PDF

man can also typeset a page as PostScript with the -t flag, which you can pipe to a PDF. On Linux (with Ghostscript installed):

man -t ls | ps2pdf - ls.pdf

On macOS, you can send that PostScript straight to Preview instead:

man -t ls | open -f -a Preview

Either way, you've got the manual in a portable format — text for quick reference, PDF for a clean printout.

← All articles