Files
tldr/pages.zh/common/join.md

24 lines
675 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# join
> 在一个公共字段上连接两个已排序文件的行。
> 更多信息:<https://www.gnu.org/software/coreutils/join>。
- 在第一个(默认)字段上连接两个文件:
`join {{path/to/file1}} {{path/to/file2}}`
- 使用逗号(而不是空格)作为字段分隔符连接两个文件:
`join -t {{','}} {{path/to/file1}} {{path/to/file2}}`
- 将file1的field3与file2的field1连接
`join -1 {{3}} -2 {{1}} {{path/to/file1}} {{path/to/file2}}`
- 为file1中每个无法配对的行生成一行
`join -a {{1}} {{path/to/file1}} {{path/to/file2}}`
-`stdin`连接一个文件:
`cat {{path/to/file1}} | join - {{path/to/file2}}`