Quote:
Originally Posted by vgersh99
It would definitely help if you provided a more detailed description of what you're trying to achieve with the sample data files and the expected output.
My crystal ball is a bit fuzzy, but:
Code:
nawk -F"," 'NR==FNR {a[$2,$3]=$1;next} ($2 SUBSEP $3) in a {print a[$2,$3],$1,$2,$3}' OFS=, file1 file2
|
vgersh99
I have two files
$ head file1
zip,FirstName,Lastname
07777,abc,def
22584,dec,dlo
25487,xyz,jkl
25488,dim,kio
$ head file2
aim server database
SSN,Firstname,LastName
123456789,abc,def
123456789,dec,dlo
123456789,xyz,jkl
123456789,dim,kio
wanted Output:
SSN,zip,FirstName,LastName
Code:
nawk -F"," 'NR==FNR {a[$2,$3]=$1;next} ($2 SUBSEP $3) in a {print a[$2,$3],$1,$2,$3}' OFS=, " file2 file1
40 Matches
Code:
nawk -F"," 'NR==FNR {a[$2,$3]=$1;next} ($2 SUBSEP $3) in a {print a[$2,$3],$1,$2,$3}' OFS=, " file1 file2
140 matches
140 matches is correct i know but both should give 140 i dont know why its giving difference.
Can you please explain this part ($2 SUBSEP $3)
a[$2,$3] we are using , here because its is comma seperated inputfile or is it general rule
If i dont use , then also i am getting same result