learningawk
Technical User
I have a file1:
aaa aaaa aa aaaa a
bbb bbbb bb bbbb b
ccc cccc cc cccc c
ddd dddd dd dddd d
eee eeee ee eeee e
fff ffff ff ffff f
ggg gggg gg gggg g
hhh hhhh hh hhhh h
I have a file2:
999.00000 999.00000 999.00000 2
999.00000 999.00000 999.00000 4
999.00000 999.00000 999.00000 7
etc.
I want to getline the value from $4 from file2 and insert the record " 999.00000 999.00000 999.00000" into file1. The field $4 is NR position of the 999.0000 record located in the output fille.
Thus the output would be:
aaa aaaa aa aaaa a
999.00000 999.00000 999.00000
bbb bbbb bb bbbb b
999.00000 999.00000 999.00000
ccc cccc cc cccc c
ddd dddd dd dddd d
999.00000 999.00000 999.00000
eee eeee ee eeee e
fff ffff ff ffff f
ggg gggg gg gggg g
hhh hhhh hh hhhh h
I'm not sure if I have to getline file2 into an array and then increment the printing of file1 or if you can just read file 2 and print required number from file 1 until end of both files encountered.
Thanks for any help.
aaa aaaa aa aaaa a
bbb bbbb bb bbbb b
ccc cccc cc cccc c
ddd dddd dd dddd d
eee eeee ee eeee e
fff ffff ff ffff f
ggg gggg gg gggg g
hhh hhhh hh hhhh h
I have a file2:
999.00000 999.00000 999.00000 2
999.00000 999.00000 999.00000 4
999.00000 999.00000 999.00000 7
etc.
I want to getline the value from $4 from file2 and insert the record " 999.00000 999.00000 999.00000" into file1. The field $4 is NR position of the 999.0000 record located in the output fille.
Thus the output would be:
aaa aaaa aa aaaa a
999.00000 999.00000 999.00000
bbb bbbb bb bbbb b
999.00000 999.00000 999.00000
ccc cccc cc cccc c
ddd dddd dd dddd d
999.00000 999.00000 999.00000
eee eeee ee eeee e
fff ffff ff ffff f
ggg gggg gg gggg g
hhh hhhh hh hhhh h
I'm not sure if I have to getline file2 into an array and then increment the printing of file1 or if you can just read file 2 and print required number from file 1 until end of both files encountered.
Thanks for any help.