Quantcast
Viewing all articles
Browse latest Browse all 13

Using awk to process a mapping file with dynamic number of columns

I’m a complete newbie to awk and am wondering how to process information as following:

mapping.txt:

80  001 002
81  011 012 013 014
82  021 022
...

input.txt:

81  103823044
80  103823054
81  103823064
...

Desired output.txt:

103823044|011|
103823044|012|
103823044|013|
103823044|014|
103823054|001|
103823054|002|
103823064|011|
103823064|012|
103823064|013|
103823064|014|

I’ve done simple mapping wherein the column numbers are fixed but I’m unsure of how to map a dynamic number of columns to the desired output


Viewing all articles
Browse latest Browse all 13

Trending Articles