开发者

Comparing two files using awk or sed

开发者 https://www.devze.com 2023-02-21 02:56 出处:网络
I ha开发者_Go百科ve two files... Lookup is 1285 lines long: cat Lookup.txt abc def ghi jkl main is 4,838,869 lines long:

I ha开发者_Go百科ve two files...

Lookup is 1285 lines long:

cat Lookup.txt 
abc
def
ghi
jkl

main is 4,838,869 lines long:

cat main.txt
abc, USA
pqr, UK
xyz, SA

I need to compare lookup and main and then output the matching lines in main to final.txt


You don't need awk or sed here but grep, assuming I am reading your requirements correctly:

% grep -f lookup.txt main.txt > final.txt
% cat final.txt 
abc, USA
0

精彩评论

暂无评论...
验证码 换一张
取 消