For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by whitespace. When FILE1 or FILE2 (not both) is -, read standard input.
`join' writes to standard output a line for each pair of input lines that have identical join fields. Synopsis:
join [OPTION]... FILE1 FILE2
Either FILE1 or FILE2 (but not both) can be `-', meaning standard input. FILE1 and FILE2 should be sorted on the join fields.
[beyes@localhost ~]$ cat temp.txt
root:x:1:kk:22:ee:duoduo:hello:yes:no
[beyes@localhost ~]$ join -t ':' temp.txt -
root:yes:ok #这里进行输入,ctrl + D 结束输入
root:x:1:kk:22:ee:duoduo:hello:yes:no:yes:ok
设 test-1.txt 中的内容为:
yes:no:duoduo:i:love:you
beyes::admin::root::qingqing
设 test-2.txt 中的内容为:
yes:hehe:haha:hoho:bebe:kiki
3:5:6:7:8:9
执行下面的命令:
[beyes@localhost com_join]$ join -t ':' -a 1 test-1.txt test-2.txt
yes:no:duoduo:i:love:you:hehe:haha:hoho:bebe:kiki
beyes::admin::root::qingqing #可见出了进行匹配连结外还输出了 test-1.txt 中不匹配的行
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |