我如何合併兩個文件時,兩個第一列這兩個文件匹配,並與第二個文件列替換第一個文件值......我的意思是......
的數目相同列:
FILE 1:
121212,0100,1.1,1.2,
121212,0200,2.1,2.2,
FILE 2:
121212,0100,3.1,3.2,3.3,
121212,0130,4.1,4.2,4.3,
121212,0200,5.1,5.2,5.3,
121212,0230,6.1,6.2,6.3,
OUTPUT:
121212,0100,3.1,3.2,3.3,
121212,0200,5.1,5.2,5.3,
換句話說,我需要打印$0
第二個文件的時候比賽$1
並在這兩個文件$2
。我理解邏輯,但我不能使用數組來實現它。這顯然應該使用。
請花點時間來解釋任何代碼。
檢查http://theunixshell.blogspot.in/2012/12/file-comparisons-using-awk-match-columns.html或這樣的:HTTP:// theunixshell。 blogspot.in/2012/12/awk-one-liner-for-multi-column.html – Vijay