pr

pr prepares text for printing on paper. It breaks a file into pages, puts a header and a trailer on each, and can arrange the text into columns.

pr [options] [file...]
$ pr report.txt

Run plainly, pr divides the input into 66-line pages, each beginning with a five-line header — the date, the file name, and a page number — and ending with a trailing margin. With no file, it reads standard input.

Columns #

pr can lay text out in several columns per page.

OptionEffect
-COLUMNProduce COLUMN columns per page (e.g. -3 for three). Text fills down the first column, then the next.
-a, --acrossFill the columns across — line 1 in column 1, line 2 in column 2, and so on — rather than down.
-m, --mergePrint several files side by side, one per column.
-w, --width=WIDTHSet the page width, for multi-column output.

The header and the page #

OptionEffect
-h, --header=TEXTUse TEXT in the header instead of the file name.
-t, --omit-headerPrint neither the header nor the trailer.
-T, --omit-paginationDrop the header, the trailer, and all pagination — just the text.
-l, --length=LINESSet the page length to LINES instead of 66.
-o, --indent=NIndent every line by N spaces.
-D, --date-format=FORMATFormat the header's date with FORMAT.
-F, -f, --form-feedSeparate pages with a form-feed character rather than blank lines.

Selecting and numbering #

OptionEffect
--pages=FIRST[:LAST]Print only pages FIRST through LAST.
-n, --number-lines[=SEP[WIDTH]]Number every line.
-N, --first-line-number=NBegin line numbering at N.
-d, --double-spaceDouble-space the output.

Other options #

OptionEffect
-s, --separator-char[=CHAR]Separate columns with a single CHAR (default tab) rather than padding with spaces.
-S, --sep-string[=STRING]Separate columns with STRING.
-e, --expand-tabs[=CHAR[WIDTH]]Expand input tabs to spaces.
-J, --join-linesMerge full lines, turning off width truncation.
-r, --no-file-warningsDo not warn when a file cannot be opened.

Exit status #

CodeMeaning
0Success.
1A file could not be read, or an option was invalid.

Edit this page