How to print a man page from the command line in Linux
Man page also called a MANual is an electronic document found commonly in all Linux and Unix operating systems. Each command will have its own
man page which explains how to use that particular command.
For example, to view the man page of the Linux command
ls, fire up a terminal and enter the following :
$ man ls
Print a man page
You can print a man page from the command line as follows :
$ man -t <command> | lpr
-t indicates that ‘
man‘ must format the manual to be used for the printer. The output of ‘
man -t‘ is in a printing language called postscript.
So for example, to print the man page of
cat command, we can do the following :
$ man -t cat | lpr
By using the command
lpr after the pipe, you are sending the output to the printer. But before you send the entire manual to the printer, it is always prudent to check the number of pages that will be send to the printer. This is done by using the
wc command as follows :
$ man cat | wc -l 71
71 lines above translates to less than a page since 80 lines fit on an A4 page. If a manual has lots more lines, dividing the lines by 80 will give you an approximate idea of the number of pages that will be used by the printer to print the manual.