# paste.1

PASTE(1)

PASTE(1)

FreeBSD General Commands Manual

PASTE(1)

## [名称](#__u540D___u79F0_)

`paste` —

合并文件的相应行或后续行

## [概要](#__u6982___u8981_)

`paste` \[`-s`] \[`-d` list] file ...

## [描述](#__u63CF___u8FF0_)

`paste` 实用程序连接给定输入文件的相应行，用单个制表符替换除最后一个文件的换行符之外的所有行，并将结果行写入标准输出。 如果在其他输入文件仍包含数据的情况下在一个输入文件上到达文件结尾，则该文件被视为无休止的空行来源。

选项如下：

[`-d`](#d) list

使用一个或多个提供的字符来替换换行符而不是默认制表符。 list 中的字符循环使用，即当 list 用尽时， list 中的第一个字符被重用。 这一直持续到显示最后一个输入文件中的一行（默认操作）或每个文件中的最后一行（使用 `-s` 选项），此时 `paste` 开始再次从 list 开头选择字符。

列表中也可以使用以下特殊字符：

换行符

制表符

[`\\`](#_e_e)

反斜杠字符

[`\0`](#_e0)

空字符串（不是空字符）。

任何其他以反斜杠开头的字符都等同于该字符本身。

[`-s`](#s)

按命令行顺序连接每个单独输入文件的所有行。 每个输入文件中除最后一行之外的每一行的换行符都替换为制表符，除非 `-d` 选项另有指定。

如果为一个或多个输入文件指定了 ‘`-`’ ，则使用标准输入；对于 ‘`-`’ 的每个实例，标准输入一次循环读取一行。

## [退出状态](#__u9000___u51FA___u72B6___u6001_)

The `paste` utility exits 0 on success, and >0 if an error occurs.

## [实例](#__u5B9E___u4F8B_)

分三列列出当前目录中的文件：

`ls | paste - - -`

将文件中的行对组合成单行：

`paste -s -d '\t\n' myfile`

对文件中的行进行编号，类似于 nl(1):

`sed = myfile | paste -s -d '\t\n' - -`

创建一个以冒号分隔的名为 bin 的目录列表，适合在 `PATH` 环境变量中使用：

`find / -name bin -type d | paste -s -d : -`

## [参见](#__u53C2___u89C1_)

cut(1), lam(1)

## [标准](#__u6807___u51C6_)

`paste` 实用程序预计与 IEEE Std 1003.2 (“POSIX.2”) 兼容。

## [历史](#__u5386___u53F2_)

`paste` 命令出现在 Version 32V AT\&T UNIX 中。

June 25, 2004

FreeBSD 13.1-RELEASE


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://man.bsdcn.org/man1/paste.1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
