{"id":1234,"date":"2019-04-28T23:48:25","date_gmt":"2019-04-28T15:48:25","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=1234"},"modified":"2019-04-28T23:48:26","modified_gmt":"2019-04-28T15:48:26","slug":"join","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/join","title":{"rendered":"join\u547d\u4ee4 – \u8fde\u63a5\u4e24\u4e2a\u6587\u4ef6"},"content":{"rendered":"\n

join\u7684\u8fde\u63a5\u64cd\u4f5c\u7b80\u8a00\u4e4b\u5c31\u662f\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u57df\u7684\u7eaa\u5f55\u7ed9\u6311\u9009\u51fa\u6765\uff0c\u518d\u5c06\u8fd9\u4e9b\u7eaa\u5f55\u6240\u6709\u7684\u57df\u653e\u5230\u4e00\u884c\u3002<\/p>\n\n\n\n

\u6ce8\u610f\uff1ajoin\u5728\u5bf9\u4e24\u4e2a\u6587\u4ef6\u8fdb\u884c\u8fde\u63a5\u65f6\uff0c\u4e24\u4e2a\u6587\u4ef6\u5fc5\u987b\u90fd\u662f\u6309\u7167\u8fde\u63a5\u57df\u6392\u597d\u5e8f\u7684\uff0c\u6309\u5176\u4ed6\u57df\u6392\u5e8f\u662f\u65e0\u6548\u7684\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>join [\u53c2\u6570] [\u6587\u4ef61] [\u6587\u4ef62]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n
-a1\u6216-a2<\/td>\u9664\u4e86\u663e\u793a\u5171\u540c\u57df\u7684\u7eaa\u5f55\u4e4b\u5916\uff0c-a1\u663e\u793a\u7b2c\u4e00\u4e2a\u6587\u4ef6\u6ca1\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55\uff0c-a2\u663e\u793a\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u4e2d\u6ca1\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55<\/td><\/tr>
-i<\/td>\u5ffd\u7565\u5927\u5c0f\u5199<\/td><\/tr>
-o<\/td>\u8bbe\u7f6e\u7ed3\u679c\u663e\u793a\u7684\u683c\u5f0f<\/td><\/tr>
-t<\/td>\u6539\u53d8\u57df\u7684\u5206\u9694\u7b26<\/td><\/tr>
-v1\u6216-v2<\/td>\u4e0d\u663e\u793a\u5171\u540c\u57df\u7684\u7eaa\u5f55\u4e4b\u5916\uff0c-v1\u663e\u793a\u7b2c\u4e00\u4e2a\u6587\u4ef6\u6ca1\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55\uff0c-v2\u663e\u793a\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u4e2d\u6ca1\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55 <\/td><\/tr>
-1\u6216-2<\/td>-1\u7528\u6765\u8bbe\u7f6e\u6587\u4ef61\u8fde\u63a5\u7684\u57df\uff0c-2\u7528\u6765\u8bbe\u7f6e\u6587\u4ef62\u8fde\u63a5\u7684\u57df<\/td><\/tr><\/tbody><\/table>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u5c06\u4e24\u4e2a\u6587\u4ef6\u7684\u5177\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55\u8fde\u63a5\u5728\u4e00\u8d77\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# cat file.db 
A li:20:men:anhui
B wang:21:women:jiangsu
C zhang:22:men:anhui
D liu:23:women:Shanghai
E chen:23:women:Hefei
[root@linuxcool ~]# cat file_hobby.db
A li:Song
B wang:shopping
C zhang:pingpong
D liu:chess
E Wang:reading
[root@linuxcool ~]# join -t: file.db file_hobby.db
A li:20:men:anhui:Song
B wang:21:women:jiangsu:shopping
C zhang:22:men:anhui:pingpong
D liu:23:women:Shanghai:chess<\/pre>\n\n\n\n

-a1\u8fd8\u663e\u793a\u7b2c\u4e00\u4e2a\u6587\u4ef6\u4e2d\u6ca1\u6709\u5171\u540c\u57df\u7684\u7eaa\u5f55\uff0c-a2\u5219\u663e\u793a\u7b2c\u4e8c\u4e2a\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# join -t: -a1 file.db file_hobby.db
A li:20:men:anhui:Song
B wang:21:women:jiangsu:shopping
C zhang:22:men:anhui:pingpong
D liu:23:women:Shanghai:chess
E chen:23:women:Hefei
[root@linuxcool ~]# join -t: -a2 file.db file_hobby.db
A li:20:men:anhui:Song
B wang:21:women:jiangsu:shopping
C zhang:22:men:anhui:pingpong
D liu:23:women:Shanghai:chess
E Wang:reading<\/pre>\n\n\n\n

\u8bbe\u7f6e\u6307\u5b9a\u683c\u5f0f\u7684\u57df\u6765\u663e\u793a\u51fa\u6765\uff08\u5c06\u5177\u6709\u5171\u540c\u7eaa\u5f55\u7684\u57df\u6309\u7167\u59d3\u540d+\u6027\u522b+\u7231\u597d\u7684\u683c\u5f0f\u663e\u793a\u51fa\u6765\uff09\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# join -t: -o1.1 1.3 2.2 file.db file_hobby.db 
A li:men:Song
B wang:women:shopping
C zhang:men:pingpong
D liu:women:chess<\/pre>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

join\u7684\u8fde\u63a5\u64cd\u4f5c\u7b80\u8a00\u4e4b\u5c31\u662f\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u57df\u7684\u7eaa\u5f55\u7ed9\u6311\u9009\u51fa\u6765\uff0c\u518d\u5c06\u8fd9\u4e9b\u7eaa\u5f55\u6240\u6709\u7684\u57df\u653e\u5230\u4e00\u884c\u3002 \u6ce8\u610f\uff1ajoin\u5728 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1234"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=1234"}],"version-history":[{"count":8,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1234\/revisions"}],"predecessor-version":[{"id":1599,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1234\/revisions\/1599"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=1234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=1234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=1234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}