0% found this document useful (0 votes)
71 views

Printing Files: The PR Command

This document discusses printing and email utilities in Unix. It focuses on using the pr command to format files for printing. The pr command can format text into multiple columns for display on screen or printing. Options for pr include specifying the number of columns, page length, headers, and offsets. An example uses pr to create a two-column report from a file listing restaurants.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

Printing Files: The PR Command

This document discusses printing and email utilities in Unix. It focuses on using the pr command to format files for printing. The pr command can format text into multiple columns for display on screen or printing. Options for pr include specifying the number of columns, page length, headers, and offsets. An example uses pr to create a two-column report from a file listing restaurants.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

In this chapter, we will discuss in detail about Printing and Email as the basic

utilities of Unix. So far, we have tried to understand the Unix OS and the nature of
its basic commands. In this chapter, we will learn some important Unix utilities that
can be used in our day-to-day life.

Printing Files
Before you print a file on a Unix system, you may want to reformat it to adjust the
margins, highlight some words, and so on. Most files can also be printed without
reformatting, but the raw printout may not be that appealing.
Many versions of Unix include two powerful text formatters, nroff and troff.

The pr Command

The pr command does minor formatting of files on the terminal screen or for a


printer. For example, if you have a long list of names in a file, you can format it
onscreen into two or more columns.
Following is the syntax for the pr command −
pr option(s) filename(s)
The pr changes the format of the file only on the screen or on the printed copy; it
doesn't modify the original file. Following table lists some pr options −

Sr.No Option & Description


.

1 -k
Produces k columns of output

2 -d
Double-spaces the output (not on all pr versions)

3 -h "header"
Takes the next item as a report header

4 -t
Eliminates the printing of header and the top/bottom margins

5 -l PAGE_LENGTH
Sets the page length to PAGE_LENGTH (66) lines. The default number
of lines of text is 56

6 -o MARGIN
Offsets each line with MARGIN (zero) spaces

7 -w PAGE_WIDTH
Sets the page width to PAGE_WIDTH (72) characters for multiple text-
column output only

Before using pr, here are the contents of a sample file named food.
$cat food
Sweet Tooth
Bangkok Wok
Mandalay
Afghani Cuisine
Isle of Java
Big Apple Deli
Sushi and Sashimi
Tio Pepe's Peppers
........
$
Let's use the pr command to make a two-column report with the
header Restaurants −
$pr -2 -h "Restaurants" food
Nov 7 9:58 1997 Restaurants Page 1

Sweet Tooth Isle of Java


Bangkok Wok Big Apple Deli
Mandalay Sushi and Sashimi
Afghani Cuisine Tio Pepe's Peppers
........
$

You might also like