[問題]比較兩個檔案特定欄位

作者: 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