There are times I want to print out a man page or redirect it to a text file for other reasons. Everytime I did man iptables > iptables.txt I got a bunch of control characters.

IPTABLES(8)                                                        IPTABLES(8)N^HNA^HAM^HME^HE       iptables - administration tool for IPv4 packet filtering and NAT

S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS

i^Hip^Hpt^Hta^Hab^Hbl^Hle^Hes^Hs [^H[-^H-t^Ht t^Hta^Hab^Hbl^Hle^He]^H] -^H-[^H[A^HAD^HD]^H] chain rule-specification [options]

i^Hip^Hpt^Hta^Hab^Hbl^Hle^Hes^Hs [^H[-^H-t^Ht t^Hta^Hab^Hbl^Hle^He]^H] -^H-I^HI chain [rulenum] rule-specification [options]

Well there a nice little utility called col which filters reverse line feeds from input. Go figure. Here’s how to get rid of the noise.
man iptables | col -b Which results in

IPTABLES(8)                            IPTABLES(8)NAME

       iptables - administration tool for IPv4 packet filtering and NAT

If you redirect the latter to a file, you can print it like any other text file. Enjoy!

3 thoughts on “printting man pages

  1. Actually, since the default pager for man is ‘less’, you can use the less ‘save to file’ command – ‘s’ – while reading the man page.

    Also, if you’re on the first line of the file, |$lpr to pipe everything from the top line to the end to the printer.

    🙂

    -RN

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s