Linux command
join 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Join on first field
join [file1] [file2]
Join on specific fields
join -1 [2] -2 [1] [file1] [file2]
Output specific fields
join -o 1.1,2.2 [file1] [file2]
Case insensitive
join -i [file1] [file2]
Show unmatched lines
join -a 1 [file1] [file2]
Custom delimiter
join -t "," [file1.csv] [file2.csv]
说明
join merges two files on a common field. It performs relational database-style joins on text files. Files must be sorted on the join field. The tool supports inner, left, and right join operations.
参数
- -1 _FIELD_
- Join on field N of file 1.
- -2 _FIELD_
- Join on field N of file 2.
- -o _FORMAT_
- Output format specification.
- -t _CHAR_
- Field delimiter.
- -i
- Ignore case differences.
- -a _FILENUM_
- Print unpairable lines.
- --help
- Display help information.
FAQ
What is the join command used for?
join merges two files on a common field. It performs relational database-style joins on text files. Files must be sorted on the join field. The tool supports inner, left, and right join operations.
How do I run a basic join example?
Run `join [file1] [file2]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -1 _FIELD_ do in join?
Join on field N of file 1.