The problem is that "man" formats the text with Ctrl-H backspaces and multiple letters to make bold text. Your printer probably will make a mess of it.
One way to strip all that out is to use "col -b":
man ls | col -b | lp
The "-t" option to "man" produces Postscript output, so if your printer (or printer driver) can handle that, you are all set. Linux cups can do that:
Linux:
man -t ls | lpr
Another way on Mac is to use Preview and print from there (which gives you access to gui print options):
Mac OS X Version:
man -t ls | open -f -a /Applications/Preview.app/
Got something to add? Send me email.
While we all ooh and ahh over the reports and graphs, Google is quietly building an incredible pile of extremely valuable information. (Tony Lawrence)
Thu Feb 14 10:18:23 2008: 3642 anonymous
man -t <command> | lpr
e.g.: man -t ls | lpr
This will give you a very nice fully formatted, comfortably readable print-out of you man page, including title and page-numbers.
2 cent.
Thu Feb 14 10:40:38 2008: 3643 TonyLawrence
On a modern Linux or BSD system, yes.. but not on the old SCO boxes this was written for..
Tue Aug 25 15:17:17 2009: 6784 anonymous
Example to produce a pdf file for grep:
man -t `man -w grep` | ps2pdf - grep.pdf
Bye. SB
Tue Aug 25 17:21:32 2009: 6785 TonyLawrence
Again, yes,but not for the crappy old systems this post referenced.
Sun Sep 6 02:20:27 2009: 6861 bofors
The solutions proposed above did not work so great for OS X or at least choked my printer.
Here is what did:
man -t "_cmd_" | open -f -a /Applications/Preview.app/
Where you replace _cmd_ with the name of the command you want to print the man page for. For example, diskutil:
man -t "diskutil" | open -f -a /Applications/Preview.app/
That generates a nice PDF to print out.
Cheers,
~bofors
Sun Sep 6 10:00:36 2009: 6862 TonyLawrence
Right.
Having this old stuff here can be confusing - that's why I have the warning ahead of the article.
It is nice to have more modern answers in the comments.
Tue Sep 15 21:38:32 2009: 6912 anonymous
man -t expect | lpr
did exactly what the man said it would.
thank you it's what i needed.
ubuntu 9.04
Sat Dec 25 07:01:45 2010: 9180 Josh
I've been looking for a command like this for quite some time now, and I use it often enough that I went ahead and made a little shell script that I find useful because remembering all of those flags is a pain in the butt. I named it "manprint" but you can name it whatever you like. Just as a side-note, errors are passed through automatically, at least on my system.
if [ $# -ne 1 ]
then
echo "Error in $0 - Invalid Argument Count"
exit
fi
echo "Expect this to take a while; that is normal... Go get some coffe while y$
man -t $1 | open -f -a /Applications/Preview.app/
exit
------------------------
Printer Friendly Version
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version