arrays - Match repetitive data from file with second column from second file -
hello have file repetitive data such:
england england england japan japan japan japan america america america
and second file unique data has 2 columns(separated "=" ), first column being considered key:
england=london japan=tokyo america=washington dc australia=sydney ireland=dublin
i trying figure out how can output second column of second file using first column matching key. output should be:
london london london tokyo tokyo tokyo tokyo washington dc washington dc washington dc
i've tried using first file array in bash , using cat on second file piped grep array search feature. output didn't equate multiple instances of array. think there way awk using arrays, haven't been able figure out in last few days.
with sed:
sed -f <(sed 's|\(.*\)=\(.*\)|s/\1/\2/|' file2) file1
output:
london london london tokyo tokyo tokyo tokyo washington dc washington dc washington dc
Comments
Post a Comment