Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

The question is: how do you print only part of a man page?

Currently I do zcat manpage.1.gz | vim - and just remove everything I don't want to print. Then I pass that through groff and lpr. Are there better methods?

share|improve this question

I know that you can print a whole man page at once, in plain monospaced text, by doing something like

man mc | col -b | lpr -P printername

Or to print it "pretty" (Serif font, bold, italics etc.) by doing

zcat /usr/share/man/man1/mc.1.gz | groff -man -Tps | lpr -P printername

As this basically sends a postscript file to the printer, you can also save it to a PostScript file by doing

zcat /usr/share/man/man1/mc.1.gz | groff -man -Tps > mc.ps

But I have no idea if you can easily extract a certain page, pages, or sections.

share|improve this answer
Some versions of the man command have a -t option as a shortcut for outputting postscript so you don't have to find the .1.gz file and type that long command, you can just man -t foo | lpr. On selecting sections, I doubt it can be done cleanly. – Alan Curry Aug 12 '12 at 19:00

How about:

man ls | sed -n "5, 8p;8q" > print_this.txt # get lines 5 to 8

Then print with

lp -d <printer> print_this.txt

(Hint: The option (-o) switches of lp are very useful!)

But better yet: open in your editor, then mark the region. In Emacs:

M-x man RET ls


M-x print-region

For this to work, the variable printer-name must be set. Or, use switches to lpr. (I see that you do not use Emacs, but this is of course possible in your editor as well.)

share|improve this answer

If you want to easily print a man doc I usually do it the graphical way:

man -Hfirefox command

Then you can print certain pages in your web browser. This isn't as powerful as doing it through the command line but it's a lot easier to get right since you can actually see what you're printing ahead of time. This may be important if you want to print a landscape document or something of that sort.

share|improve this answer
This is the best answer. – Mustafa Serdar Şanlı Jan 23 '15 at 11:59

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.