Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get man pages to stout. However, I have not managed a way to do that.

Pseudo-code about what I am trying to achieve

man man | lpr

How can you print a manual, such that you see first how many pages is going to be printed?

share|improve this question
up vote 2 down vote accepted
man -Tps man | lpr

This tells man to format the output as a postscript file which can be piped directly to a printer. See the man page for further -T (troff) formatting options.

To preview the output pipe it to a file and view it with gv or okular.

man -Tps man >
share|improve this answer
Do you know how you can get the number of pages before you print the manual? – Masi Jun 2 '09 at 21:15
See my edits above, I can't think of a way to count the pages from the command line. – Sekenre Jun 2 '09 at 21:26
@sekenre: I get the following error message: – Masi Jun 26 '09 at 14:30
It seems that OS/X's man does not have the option T. – Masi Jun 26 '09 at 14:34
@Masi: Try using man -t python | lpr Your version has that option. – Sekenre Jun 27 '09 at 19:51

man ls | col -b | lpr -P my_printer

This prints the man page for "ls" formats it using "col" and then prints on the printer named "my_printer"

The formatting isn't required, but gets rid of special characters making it easier to read.

share|improve this answer

Newer versions of man (at least my version on openSuSE 11 :) ) automatically detect if output is a terminal or a pipe. If you want non-formatted man pages to stdout, try:

man man | cat

For manpages going to the printer, I like:

man man | a2ps --stdin='man(1)'
share|improve this answer

Answer to # of pages question above(need 50 rep to add comments):

man ls | wc -l | awk '{ print $1/60 }'

The default # of lines per page is 60, so if you aren't changing that, then just divide by 60 and round up. I forget how to make awk treat FP as INT so that it rounds for you.

share|improve this answer
@Josh: What is FP? – Masi Jun 26 '09 at 14:32
sorry for the late response. FP = floating point; INT = integer. It would be useful to have it translated into an INT if you were planning on using the output for another automated purpose(ie - piping a one liner or in a script). – Josh Jul 2 '09 at 5:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.