I have two input files:
input1 is the file I need to process, input1 file example:
efgdx
efgfx
aa
efgdx
b
efgdx
input2 file tells what characters need to be add to which line, for example:
2,abcd
4,efg
5,hij
So, "abcd" should be added to the front of 2nd line, "efg" should be added to the front of 4th line, ...
This is the output I want:
efgdx
abcdefgfx
aa
efgefgdx
hijb
efgdx
I tried the following code but it will add strings to every line
awk '!p { getline m < "input2"; split(m, a, ","); p = 1} NR == a[1] {p=0} 1 { print a[2] $0}' input1
output from above code:
abcdefgdx
abcdefgfx
efgaa
efgefgdx
hijb
hijefgdx
Thanks very much for your inputs!