How do I print out a Linux man or info page?
Some time it is necessary to print a Linux man or info page. To print a ls command man page on command line type following command:
$ man ls | col -b | lpr -P hp1_floor2
Where,
col -b : To format man page output, it will not show any special character such as backspaces
lpr -P hp1_floor2 : hp1_floor2 is the printer name of the Linux/UNIX printer queue
To print the man page with effects such as italic and bold fonts on HP Laser Jet printer:
$ zcat /usr/share/man/man1/ls.1.gz | groff -man -Tps | lpr -P hp1_floor2
Or save man page as ps file:
zcat /usr/share/man/man1/ls.1.gz | groff -man -Tps >top.ps
Where,
zcat : Open compress /usr/share/man/man1/ls.1.gz file
groff : Go through groff document formatting system, which is responsible for formatting of man page with ffects such as italic and bold fonts on both screen and printer
lpr -P hp1_floor2 : hp1_floor2 is the printer name of the Linux/UNIX printer queue
Here is a shell script that we have installed on all Linux workstations, it saves man page in a text file and later user can print it using lpr command.
#!/bin/bash # Linux shell script to save man pages to text file # so that later user can print them CMDS="$@" OUTDIR="/tmp/$USER.man" [ ! -d $OUTDIR ] && mkdir -p $OUTDIR : for i in $CMDS do man $i col -b > $OUTDIR/$i.txt done echo "**********************************************************" echo "All man pages saved to $OUTDIR directory" echo "Just goto \"$OUTDIR\" directory and type following command to print page:" echo "lpr *.txt" echo "**********************************************************" exit 0
Just type the script-name followed by Linux commands, for example to print a man page of ls and bash type
$ saveman "ls bash"
Related: How do I print or make hard copies of Linux man and info pages?
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Print / Select a paper size other than A4 when using lp command line utility
- Linux: How to Encrypt and decrypt files with a password
- Howto: Linux Configure Pass-Thru Print
- FreeBSD install man, info pages and other package set
- Perl script to monitor disk space and send an email
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bash linux, bold fonts, command man, document formatting system, echo exit, groff document, hp laser jet, hp1, laser jet printer, linux commands, linux man, linux workstations, lpr command, man ls, man page, print man page, printer lpr, printer name, ps file, shell script, unix printer



Recent Comments
Today ~ 1 Comment
Today ~ 31 Comments
Today ~ 17 Comments
Today ~ 1 Comment
Today ~ 12 Comments