Examples of using the pr command

To preview a file:

   pr chapter3.txt

This displays the contents of the file chapter3.txt one page after the other.


To preview a file using a pager:

   pr part2.txt | less

This displays the contents of the file part2.txt with the output piped through the pager program less to prevent it scrolling out of sight.


To change the appearance of the previewed file:

   pr -l 40 -h Using Hypertext comms_paper | more

This prints the file comms_paper to the screen, using a page length of 40 lines, with the title "Using Hypertext" instead of the filename. The output is piped through the pager program more to stop it scrolling out of sight.


To prepare a file and then print it:

   pr -n2 | lpr

This prepares the file for printing in two columns, separated into "pages" of 66 lines, with a 5 line header and footer. The header contains a single line giving the name of the file and other information.

The output is then piped into the lpr command and printed to the default printer.


[Home] [Search] [Index] This site maintained by webmaster@cs.auckland.ac.nz