Sometimes you want to save man command output to a file for reading in an editor or sharing. Simple redirection mixes in control characters, so proper post-processing is needed.
Using col -b
man <command> | col -b > <filename>.txtExample
man ls | col -b > ls_manual.txtThis creates plain text that won’t be garbled when opened in a regular text editor.
Why Plain Redirection Doesn’t Work
man ls > ls_bad.txtSaving like this outputs control characters like backspaces (used by man for formatting like bold and underline, appearing as ^H, etc.) directly into the file. It becomes very hard to read in editors other than less.
col -b filters these out, leaving only the text as it appears.
Saving as PDF
For printing purposes or when you want PDF, go through PostScript.
macOS
man -t ls | pstopdf -i -o ls_manual.pdfLinux
man -t ls > ls.psps2pdf ls.ps ls_manual.pdfThe -t option outputs in PostScript format, which is then converted to PDF.
Summary of Options
| Method | Command | Use Case |
|---|---|---|
| Plain text | man … | col -b |
| man -t … | pstopdf | |
| HTML | man2html | Browser display |
Personally, plain text is the most practical. Searching and processing is easy.
hsb.horse