我的输入文件:价值观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