pr [OPTION]... [FILE]...
!subtitle:功能
对文件进行分页或分栏处理以进行打印。
!subtitle:类型
可执行文件(/usr/bin/pr),属于 coreutils。
!subtitle:参数
OPTION 选项:
+FIRST_PAGE[:LAST_PAGE], --pages=FIRST_PAGE[:LAST_PAGE]
从指定的第一页开始打印(可选指定最后一页)。
-COLUMN, --columns=COLUMN
以 COLUMN 列输出,并按列 自上而下 排列(除非使用 -a)。
平衡每页各列的行数。
-a, --across
按 横向 排列列,而不是纵向。需配合 -COLUMN 使用。
-c, --show-control-chars
使用帽子符号(^G)和八进制反斜线表示控制字符。
-d, --double-space
输出结果双倍行距。
-D, --date-format=FORMAT
使用 FORMAT 指定页眉中的日期格式。
-e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]]
将输入中的 CHAR(默认 TAB)扩展为给定宽度(默认 8)。
-F, -f, --form-feed
用换页符代替换行符分隔页面:
使用 -F → 页眉占 3 行
未使用 -F → 页眉和页脚共占 5 行
-h, --header=HEADER
在页眉使用居中的 HEADER 替代文件名。
使用 -h "" 输出空白行(不要写成 -h"")。
-i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]]
将空格转换为 CHAR(默认 TAB),宽度为 WIDTH(默认 8)。
-J, --join-lines
合并完整行;关闭 -W 的行截断;不进行列对齐。
可使用 --sep-string=STRING 设置列分隔符。
-l, --length=PAGE_LENGTH
设置页面长度为 PAGE_LENGTH(默认 66 行)。
默认正文为 56 行;使用 -F 时正文为 63 行。
如果长度 ≤ 10,则隐含启用 -t(不显示页眉页脚)。
-m, --merge
并行打印多个文件,每个文件一列。
截断行;若配合 -J 则合并完整行。
-n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]]
为行编号。
DIGITS(默认 5)为编号位数;SEP(默认 TAB)为分隔符。
默认从文件第一行开始编号。
-N, --first-line-number=NUMBER
设置输出第一页第一行从 NUMBER 开始编号(参考 +FIRST_PAGE)。
-o, --indent=MARGIN
每行前缩进 MARGIN 个空格。
不影响 -w 与 -W。
MARGIN 会加到页面宽度中。
-r, --no-file-warnings
当文件无法打开时不显示警告。
-s[CHAR], --separator[=CHAR]
用单个 CHAR 分隔列。
CHAR 默认是 TAB(无 -w 时)或“无字符”(使用 -w 时)。
使用 -s 会关闭所有列模式(-COLUMN、-a、-m)的行截断,除非设置了 -w。
-S[STRING], --sep-string[=STRING]
使用 STRING 分隔列。
默认分隔符:
使用 -J → TAB
未使用 -J → 空格(相当于 -S" ")
不影响列模式。
-t, --omit-header
不输出页眉和页脚。
页面长度 ≤ 10 时自动启用。
-T, --omit-pagination
不输出页眉和页脚,并忽略输入中的分页符。
-v, --show-nonprinting
使用八进制反斜线表示不可打印字符。
-w, --width=PAGE_WIDTH
设置页面宽度为 PAGE_WIDTH(默认 72)。
仅用于多列文本输出。
使用 -s 会关闭默认页宽 72 的限制。
-W, --page-width=PAGE_WIDTH
始终设置页面宽度为 PAGE_WIDTH(默认 72)。
截断行(除非使用 -J)。
与 -S 和 -s 不冲突。
--help - 显示帮助
--version - 显示版本
FILE - 文件列表,如果没有这个参数或指定为 -,则读取标准输入
$ man pr > 1.txt # 创建文件
$ pr -n -l 20 1.txt +3:5 # 打印 1.txt 显示行号 每页 20 行 显示第三页到第五页
2025-11-23 14:09 1.txt Page 3
21 output COLUMN columns and print columns down, unless -a is used.
22 Balance number of lines in the columns on each page
23
24 -a, --across
25 print columns across rather than down, used together with -COL‐
26 UMN
27
28 -c, --show-control-chars
29 use hat notation (^G) and octal backslash notation
30
2025-11-23 14:09 1.txt Page 4
31 -d, --double-space
32 double space the output
33
34 -D, --date-format=FORMAT
35 use FORMAT for the header date
36
37 -e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]]
38 expand input CHARs (TABs) to tab WIDTH (8)
39
40 -F, -f, --form-feed
2025-11-23 14:09 1.txt Page 5
41 use form feeds instead of newlines to separate pages (by a
42 3-line page header with -F or a 5-line header and trailer with‐
43 out -F)
44
45 -h, --header=HEADER
46 use a centered HEADER instead of filename in page header, -h ""
47 prints a blank line, don't use -h""
48
49 -i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]]
50 replace spaces with CHARs (TABs) to tab WIDTH (8)
PR(1) User Commands PR(1)
NAME
pr - convert text files for printing
SYNOPSIS
pr [OPTION]... [FILE]...
DESCRIPTION
Paginate or columnate FILE(s) for printing.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options
too.
+FIRST_PAGE[:LAST_PAGE], --pages=FIRST_PAGE[:LAST_PAGE]
begin [stop] printing with page FIRST_[LAST_]PAGE
-COLUMN, --columns=COLUMN
output COLUMN columns and print columns down, unless -a is used.
Balance number of lines in the columns on each page
-a, --across
print columns across rather than down, used together with -COL‐
UMN
-c, --show-control-chars
use hat notation (^G) and octal backslash notation
-d, --double-space
double space the output
-D, --date-format=FORMAT
use FORMAT for the header date
-e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]]
expand input CHARs (TABs) to tab WIDTH (8)
-F, -f, --form-feed
use form feeds instead of newlines to separate pages (by a
3-line page header with -F or a 5-line header and trailer with‐
out -F)
-h, --header=HEADER
use a centered HEADER instead of filename in page header, -h ""
prints a blank line, don't use -h""
-i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]]
replace spaces with CHARs (TABs) to tab WIDTH (8)
-J, --join-lines
merge full lines, turns off -W line truncation, no column align‐
ment, --sep-string[=STRING] sets separators
-l, --length=PAGE_LENGTH
set the page length to PAGE_LENGTH (66) lines (default number of
lines of text 56, and with -F 63). implies -t if PAGE_LENGTH <=
10
-m, --merge
print all files in parallel, one in each column, truncate lines,
but join lines of full length with -J
-n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]]
number lines, use DIGITS (5) digits, then SEP (TAB), default
counting starts with 1st line of input file
-N, --first-line-number=NUMBER
start counting with NUMBER at 1st line of first page printed
(see +FIRST_PAGE)
-o, --indent=MARGIN
offset each line with MARGIN (zero) spaces, do not affect -w or
-W, MARGIN will be added to PAGE_WIDTH
-r, --no-file-warnings
omit warning when a file cannot be opened
-s[CHAR], --separator[=CHAR]
separate columns by a single character, default for CHAR is the
<TAB> character without -w and 'no char' with -w. -s[CHAR]
turns off line truncation of all 3 column options (-COLUMN|-a
-COLUMN|-m) except -w is set
-S[STRING], --sep-string[=STRING]
separate columns by STRING, without -S: Default separator <TAB>
with -J and <space> otherwise (same as -S" "), no effect on col‐
umn options
-t, --omit-header
omit page headers and trailers; implied if PAGE_LENGTH <= 10
-T, --omit-pagination
omit page headers and trailers, eliminate any pagination by form
feeds set in input files
-v, --show-nonprinting
use octal backslash notation
-w, --width=PAGE_WIDTH
set page width to PAGE_WIDTH (72) characters for multiple
text-column output only, -s[char] turns off (72)
-W, --page-width=PAGE_WIDTH
set page width to PAGE_WIDTH (72) characters always, truncate
lines, except -J option is set, no interference with -S or -s
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by Pete TerMaat and Roland Huebner.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Full documentation <https://www.gnu.org/software/coreutils/pr>
or available locally via: info '(coreutils) pr invocation'
GNU coreutils 9.4 April 2024 PR(1)