[问题]比较两个档案特定字段

楼主: jacobcan118 (jacobcan118)   2015-11-10 10:59:02
请问各位在unix有什么比较好的方法用shell script可以比较两个档案中第其中一字段的值.两个档案会
1:每行所含的资料顺序不一定一样,有资料在档案A出现在档案B不一定出现
2:想比较第三栏(yes, no,empty)的值

File A:
$cat A.log
case1,0.0001,yes
case2,0.0021,no
case3,0.0041,no
case4,0.0041,empty
case5,0.0101,empty
case6,0.0501,yes
File B:
$cat A.log
case1,0.0001,yes
case7,0.0021,yes
case2,0.0041,yes
case3,0.0041,empty
希望output:
case2 no yes:case3 no empty:case4 empty " ":case5 empty " ":case6 yes " ":case7 " " yes.
作者: redshoe (Red)   2015-11-11 11:10:00
sed,sort ,diff,awk,pipe ?
作者: kerwinhui (kezza)   2015-11-11 12:44:00
先sort再用join的-o
楼主: jacobcan118 (jacobcan118)   2015-11-12 12:22:00
感谢 sort + join有用

Links booklink

Contact Us: admin [ a t ] ucptt.com