Quote:
Originally Posted by vgersh99
Say 'few fields from file B' means fields 1, 3 and 5
Code:
nawk -F, 'FNR==NR{a[$4]= $3 OFS $4 OFS $5 OFS $6 OFS $7;next} $1 in a{print a[$4] OFS $1 OFS $3 OFS $5}' OFS=, fileA fileB
|
Its giving wrong output and i figured it out :
It is because of duplicate in field 4 of fileA and $1 field in fileB will also have duplicates.
Say suppose file A in 4th field has 2 times
ABC
ABC
And fileB in 1st field has 7 times
ABC
ABC
ABC
ABC
ABC
ABC
ABC
Hence my output file should have 14 times ABC
But i am getting ABC only 7 times.
Appreciate help