← 返回命令列表

Linux command

pr 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Format file for printing

pr [file]

Add page header

pr -h "[Header Text]" [file]

Multi-column output

pr -[3] [file]

Double space output

pr -d [file]

Number lines

pr -n [file]

说明

pr formats text files for printing by adding page headers (with filename and date), footers, page breaks, and line numbers. It can arrange text into multiple columns and control page dimensions including length, width, and margins. This traditional Unix utility is useful for preparing plain text documents for printing or for creating formatted multi-column layouts from single-column input. It reads from files or stdin and writes to stdout.

参数

-h _HEADER_
Page header text.
-NUM
Number of columns.
-d
Double space.
-n
Number lines.
-l _LINES_
Page length.
-w _WIDTH_
Page width.
-m
Merge files side by side.
-t
Omit headers and footers.
-s _CHAR_
Separate columns with character.

FAQ

What is the pr command used for?

pr formats text files for printing by adding page headers (with filename and date), footers, page breaks, and line numbers. It can arrange text into multiple columns and control page dimensions including length, width, and margins. This traditional Unix utility is useful for preparing plain text documents for printing or for creating formatted multi-column layouts from single-column input. It reads from files or stdin and writes to stdout.

How do I run a basic pr example?

Run `pr [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -h _HEADER_ do in pr?

Page header text.