我的輸入文件:價值觀AWK失蹤
file1
231|35000
234|15000
242|60000
254|12313
345|50000
435|24300
file2
1|madhan|retl|231|tcs
2|vaisakh|retl|234|tcs
4|sam|ins|242|infy
5|tina|bfs|254|tcs
3|ram|bfs|345|infy
6|subbu|bfs|435|infy
輸出繼電器: 試圖讓
col1 , col2 of file1 and col2 of file2 based on common column(col1 of file1 and col4 of file2)
我的代碼:
awk 'BEGIN { FS="|";} NR==FNR{a[$1] = $2;next} ($4 in a) {print $2 "|" $4 "|" a[$1]} ' file_1 file_2
O/PI有:
madhan|231|
vaisakh|234|
sam|242|
tina|254|
ram|345|
subbu|435|
你能幫爲什麼最後關口即將空格
感謝Jotne。但是如果我的輸入文件有數百萬條記錄,awk的工作效率會如何? – Madan 2015-02-24 09:43:00
@Madan'awk'可以工作,但你需要測試它看看需要多長時間。 – Jotne 2015-02-24 10:07:06