OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

pr – Convert Text Files For Printing

We looked at pr a little in the previous chapter. Now we will examine some of its many options used in conjunction with printing. In our history of printing, we saw how charac- ter-based printers use monospaced fonts, resulting in fixed numbers of characters per line and lines per page. pr is used to adjust text to fit on a specific page size, with optional page headers and margins. Here is a summary of its most commonly used options:


Table 22-1: Common pr Options


Option Description

Option Description


image

+first[:last] Output a range of pages starting with first and, optionally, ending with last.


image

-columns Organize the content of the page into the number of columns specified by columns.


image

-a By default, multicolumn output is listed vertically. By adding the -a (across) option, content is listed horizontally.


image

-d Double-space output.


image

-Dformat” Format the date displayed in page headers using format. See the man page for the date command for a description of the format string.


image

-f Use form feeds rather than carriage returns to separate pages.


image

-h “headerIn the center portion of the page header, use header rather than the name of the file being processed.


image

-l length Set page length to length. Default is 66 (US letter at 6 lines per inch)


image

-n Number lines.


image

-o offset Create a left margin offset characters wide.


image

-w width Set page width to width. Default is 72.


image


pr is often used in pipelines as a filter. In this example, we will produce a directory list- ing of /usr/bin and format it into paginated, three-column output using pr:


image

[me@linuxbox ~]$ ls /usr/bin | pr -3 -w 65 | head


2016-02-18 14:00 Page 1


[

apturl

bsd-write

411toppm

ar

bsh

a2p

arecord

btcflash

a2ps

arecordmidi

bug-buddy

a2ps-lpr-wrapper

ark

buildhash


Top OS Cloud Computing at OnWorks: