pr

v0.0.28
pr [OPTION]... [FILE]...

Write content of given file or standard input to standard output with pagination filter

Options

--pages=<FIRST_PAGE[:LAST_PAGE]>

Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]

--header=<STRING>, -h <STRING>

Use the string header to replace the file name in the header line.

--double-space, -d

Produce output that is double spaced. An extra character is output following every found in the input.

--number-lines=<[char][width]>, -n <[char][width]>

Provide width digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any non-digit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a . Line numbers longer than width columns are truncated.

--first-line-number=<NUMBER>, -N <NUMBER>

start counting with NUMBER at 1st line of first page printed

--omit-header, -t

Write neither the five-line identifying header nor the five-line trailer usually supplied for each page. Quit writing after the last line of each file without spacing to the end of the page.

--length=<PAGE_LENGTH>, -l <PAGE_LENGTH>

Override the 66-line default (default number of lines of text 56, and with -F 63) and reset the page length to lines. If lines is not greater than the sum of both the header and trailer depths (in lines), the pr utility shall suppress both the header and trailer, as if the -t option were in effect.

--no-file-warnings, -r

omit warning when a file cannot be opened

--form-feed, -F

Use a for new pages, instead of the default behavior that uses a sequence of s.

--width=<width>, -w <width>

Set the width of the line to width column positions for multiple text-column output only. If the -w option is not specified and the -s option is not specified, the default width shall be 72. If the -w option is not specified and the -s option is specified, the default width shall be 512.

--page-width=<width>, -W <width>

set page width to PAGE_WIDTH (72) characters always, truncate lines, except -J option is set, no interference with -S or -s

--across, -a

Modify the effect of the - column option so that the columns are filled across the page in a round-robin order (for example, when column is 2, the first input line heads column 1, the second heads column 2, the third is the second line in column 1, and so on).

--column=<column>

Produce multi-column output that is arranged in column columns (the default shall be 1) and is written down each column in the order in which the text is received from the input file. This option should not be used with -m. The options -e and -i shall be assumed for multiple text-column output. Whether or not text columns are produced with identical vertical lengths is unspecified, but a text column shall never exceed the length of the page (see the -l option). When used with -t, use the minimum number of lines to write the output.

--separator=<char>, -s <char>

Separate text columns by the single character char instead of by the appropriate number of s (default for char is the character).

--sep-string=<string>, -S <string>

separate columns by STRING, without -S: Default separator with -J and otherwise (same as -S" "), no effect on column options

--merge, -m

Merge files. Standard output shall be formatted so the pr utility writes one line from each file specified by a file operand, side by side into text columns of equal fixed widths, in terms of the number of column positions. Implementations shall support merging of at least nine file operands.

--indent=<margin>, -o <margin>

Each line of output shall be preceded by offset s. If the -o option is not specified, the default offset shall be zero. The space taken is in addition to the output line width (see the -w option below).

-J

merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators

--help

Print help information

+PAGE Begin output at page number page of the formatted input. -COLUMN Produce multi-column output. See --column

The pr utility is a printing and pagination filter for text files. When multiple input files are specified, each is read, formatted, and written to standard output. By default, the input is separated into 66-line pages, each with

  • A 5-line header with the page number, date, time, and the pathname of the file.
  • A 5-line trailer consisting of blank lines.

If standard output is associated with a terminal, diagnostic messages are suppressed until the pr utility has completed processing.

When multiple column output is specified, text columns are of equal width. By default, text columns are separated by at least one <blank>. Input lines that do not fit into a text column are truncated. Lines are not truncated under single column output.

Examples

Print multiple files with a default header and footer:

pr {{path/to/file1 path/to/file2 ...}}

Print with a custom centered header:

pr -h "{{header}}" {{path/to/file1 path/to/file2 ...}}

Print with numbered lines and a custom date format:

pr -n -D "{{format}}" {{path/to/file1 path/to/file2 ...}}

Print all files together, one in each column, without a header or footer:

pr -m -T {{path/to/file1 path/to/file2 ...}}

Print, beginning at page 2 up to page 5, with a given page length (including header and footer):

pr +2:5 -l {{page_length}} {{path/to/file1 path/to/file2 ...}}

Print with an offset for each line and a truncating custom page width:

pr -o {{offset}} -W {{width}} {{path/to/file1 path/to/file2 ...}}

The examples are provided by the tldr-pages project under the CC BY 4.0 License.

Please note that, as uutils is a work in progress, some examples might fail.