pr(1)
Format text files for printing with pagination, headers, footers, and multi-column layouts.
Synopsis
pr [OPTION]... [FILE]...Description
pr prepares text files for printing or display by adding headers, footers, page numbers, and margins. It can arrange output in multiple columns, apply line numbering, and handle page breaks intelligently.
By default, pr reads from standard input or specified files and outputs formatted pages with a header showing filename, date, and page number. Each page is separated by a form feed character.
Common options
| Flag | What it does |
|---|---|
-n | number all lines; use -nN to set number width |
-d | double-space the output (skip blank lines) |
-h HEADER | replace filename with custom header string |
-l LINES | set page length in lines (default 66) |
-w WIDTH | set page width in characters (default 72) |
-m | print files side-by-side in columns |
-t | suppress page headers and footers |
-p | pause before each page (for interactive viewing) |
-o MARGIN | set left margin in spaces |
+PAGE | start printing from PAGE number |
-COLUMNS | print in COLUMNS columns; separate by spaces not tabs |
Examples
Format document.txt with headers and footers, then send to printer
pr document.txt | lprAdd line numbers to report.txt with 50-line pages, save to file
pr -n -l 50 report.txt > report_formatted.txtDisplay data.txt in 3 columns with 132-character page width
pr -3 -w 132 data.txtPrint file1.txt and file2.txt side-by-side with custom header
pr -h 'Monthly Report' -m file1.txt file2.txtAdd line numbers without headers, footers, or page formatting
pr -t -n file.txtStart printing from page 5 of document.txt
pr +5 document.txtDouble-space output with 4-space left margin
pr -d -o 4 input.txtFormat with 40-line pages and 80-character width
pr -l 40 -w 80 long_file.txt > split.txt