Results 1 to 3 of 3
Hi i hope some awk gurus here can help me.. here is what i need i have 2 files:
File1
152445 516532 405088.pdf
152445 516533 405089.pdf
152491 516668 405153.jpg
152491 ...
- 05-07-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 3
awk compare 2 files
Hi i hope some awk gurus here can help me.. here is what i need i have 2 files:
File1
152445 516532 405088.pdf
152445 516533 405089.pdf
152491 516668 405153.jpg
152491 520977 408779.jpg
152491 0 409265.pdf
File2
516532 /tmp/MainStreet_Sum09_Front_FNL.pdf
516533 /tmp/MainStreet_Sum09_Back_FNL.pdf
516668 /tmp/BMRBusinessCard2.jpg
520977 /tmp/BMRBusinessCard.jpg
output
152445 516532 405088.pdf /tmp/MainStreet_Sum09_Front_FNL.pdf
152445 516533 405089.pdf /tmp/MainStreet_Sum09_Back_FNL.pdf
152491 516668 405153.jpg /tmp/BMRBusinessCard2.jpg
152491 520977 408779.jpg /tmp/BMRBusinessCard.jpg
152491 0 409265.pdf
Thanks in advance
- 05-08-2009 #2
So, just to clarify, you want to create the output shown in your post from the files above? It's just that you said "here is what i need" and then just listed stuff...
When I find myself burried in errors, Windows Help appears to me; speaking words of wisdom, Reboot!
- 05-08-2009 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
if you have Python and able to use it
output:Code:d={} for line in open("file1"): line=line.strip().split() d.setdefault(line[1],[]) d[line[1]].extend([line[0],line[2]]) for line in open("file2"): line=line.strip().split() print d[line[0]][0], line[0],d[line[0]][1],line[-1]
Code:# ./test.py 152445 516532 405088.pdf /tmp/MainStreet_Sum09_Front_FNL.pdf 152445 516533 405089.pdf /tmp/MainStreet_Sum09_Back_FNL.pdf 152491 516668 405153.jpg /tmp/BMRBusinessCard2.jpg 152491 520977 408779.jpg /tmp/BMRBusinessCard.jpg


Reply With Quote