I have 2 files, Zipcode.txt
and Address.csv
:
ZipCode.txt
12345
23456
34567
45678
Address.csv
12345,3587 main st,apt j1,city,new jersey
23456,4215 1st st. s.,suite a2,city,new jersey
65432,115 main st,,city,new jersey
45678,654 2nd st n.,city,new jersey
If the zipcode field in Zipcode.txt
matches the zipcode field in Address.csv
, I want to change the 4th field from city
to found
. Here's what I want:
12345,3587 main st,apt j1,found,new jersey
23456,4215 1st st. s.,suite a2,found,new jersey
65432,115 main st,,city,new jersey
45678,654 2nd st n.,found,new jersey
This is what I have tried:
awk -F',' 'BEGIN{OFS=FS}NR==FNR{a[$1]=1;next}a[$1]{$4="found"}1' Address.csv ZipCode.txt