Join

来自WordPress中文文档
跳转至: 导航搜索

Linux命令:join

功能说明:将两个文件中,指定栏位内容相同的行连接起来。
语  法:join [-i][-a<1或2>][-e<字符串>][-o<格式>][-t<字符>][-v<1或2>][-1<栏位>][-2<栏位>][--help][--version][文件1][文件2]
补充说明:找出两个文件中,指定栏位内容相同的行,并加以合并,再输出到标准输出设备。
参  数:
 -a<1或2>   除了显示原来的输出内容之外,还显示指令文件中没有相同栏位的行。
 -e<字符串>   若[文件1]与[文件2]中找不到指定的栏位,则在输出中填入选项中的字符串。
 -i或--igore-case   比较栏位内容时,忽略大小写的差异。
 -o<格式>   按照指定的格式来显示结果。
 -t<字符>   使用栏位的分隔字符。
 -v<1或2>   跟-a相同,但是只显示文件中没有相同栏位的行。
 -1<栏位>   连接[文件1]指定的栏位。
 -2<栏位>   连接[文件2]指定的栏位。
 --help   显示帮助。
 --version   显示版本信息。 


英文版本,欢迎翻译:

ABOUT JOIN

The join command forms, on the standard output, a join of the two relations specified by the lines of file1 and file2.

SYNTAX

join [-a filenumber | -v filenumber ] [ -1 fieldnumber ] [ -2 fieldnumber ] [ -o list ] [ -e string ] [ -t char ] file1 file2

join [ -a filenumber ] [ -j fieldnumber ] [-j1 fieldnumber ] [ -j2 fieldnumber ] [ -o list ] [-e string ] [ -t char ] file1 file2

-a filenumber In addition to the normal output, produce a line for each unpairable line in file filenumber, where filenumber is 1 or 2. If both -a 1 and -a 2 are specified, all unpairable lines will be output. -v filenumber Instead of the default output, produce a line only for each unpairable line in filenumber, where filenumber is 1 or 2. If both -v 1 and -v 2 are specified, all unpairable lines will be output. -l fieldnumber Join on the fieldnumberth field of file 1 . Fields are decimal integers starting with 1. -2 fieldnumber Join on the fieldnumberth field of file 2. Fields are decimal integers starting with 1. -j fieldnumber Equivalent to -1fieldnumber -2fieldnumber. -j1 fieldnumber Equivalent to -1fieldnumber. -j2 fieldnumber Equivalent to -2fieldnumber Fields are numbered starting with 1. -o list Each output line includes the fields specified in list. Fields selected by list that do not appear in the input will be treated as empty output fields. (See the -e option.) Each element of which has the either the form filenumber.fieldnumber, or 0, which represents the join field. The common field is not printed unless specifically requested. -e string Replace empty output fields with string. -t char Use character char as a separator. Every appearance of char in a line is significant. The character char is used as the field separator for both input and output. With this option specified, the collating term should be the same as sort without the -b option. file1 file2

File name and/or Directory and file name of the files being joined