例如: 我现在有两个文件,一个是:employee.txt,另一个是bonux.txt,彼此行记录一一对应〉
[[email protected] hack101]$ cat employee.txt 100 Jason Smith 200 John Doe 300 Sanjay Gupta 400 Ashok Sharma [[email protected] hack101]$ cat bonus.txt 100 $5,000 200 $500 300 $3,000 400 $1,250 [[email protected] hack101]$ jion employee.txt bonus.txt -bash: jion: command not found [[email protected] hack101]$ join employee.txt bonus.txt 100 Jason Smith $5,000 200 John Doe $500 300 Sanjay Gupta $3,000 400 Ashok Sharma $1,250
如果bonux.txt文件中间少了一个记录,那么该行记录就不会被combine。
[[email protected] hack101]$ cat bonus.txt 100 $5,000 200 $500 400 $1,250 [[email protected] hack101]$ join employee.txt bonus.txt 100 Jason Smith $5,000 200 John Doe $500 400 Ashok Sharma $1,250
如果bonus.txt文件中间多了一行记录,虽然该记录无法匹配,但后面的记录可以匹配〉
[[email protected] hack101]$ cat bonus.txt 100 $5,000 200 $500 201 $201 300 $oo 400 $1,250 [[email protected] hack101]$ join employee.txt bonus.txt 100 Jason Smith $5,000 200 John Doe $500 300 Sanjay Gupta $oo 400 Ashok Sharma $1,250
经过测试得知:只要被修改的记录是按共同域的合理顺序来排序的,那么linux就可以做到正常的排序, 如下:
[[email protected] hack101]$ cat bonus.txt 100 $5,000 200 $500 201 $201 202 $333 300 $oo 400 $222 401 $1,250 [[email protected] hack101]$ join employee.txt bonus.txt 100 Jason Smith $5,000 200 John Doe $500 300 Sanjay Gupta $oo 400 Ashok Sharma $222
但是如果顺序不合理的话,linux就不会按正确的顺序来匹配〉
例如:
[[email protected] hack101]$ cat bonus.txt 100 $5,000 200 $500 301 $201 302 $333 300 $oo 400 $222 401 $1,250 [[email protected] hack101]$ join employee.txt bonus.txt 100 Jason Smith $5,000 200 John Doe $500 join: file 2 is not in sorted order 400 Ashok Sharma $222
--EOF--