I have no experience with awk, sed, grep and etc. Trying to phrase my question makes it seem more confusing than it should so I will start with an example of what I am trying to achieve.
input1
A B C D
A B C
A B C D E F
input2
v A
c B
c C
c D
v E
output
A B C D
v c c c
A B C
v c c
A B C D E F
v c c c v Ø
so basically I have 2 input files.
input1 where each line has a different number of fields.
input2 where every line has 2 fields.
I need an output where for each line in input1 it will first print the full line with all its fields, then for the following line of output, it will lookup the content of each field of that line from input1 in the second field of input2. Then print the first field of that line from input2, or an Ø in case that content is not found in input2. Repeat that until the last field, printing the results in a single line. Then do the same for each line in input1.
As I will be doing slightly different tasks like this, a brief explanation of what each part of the commands does would be highly appreciated. Thanks in advance.