Replace Contents from One file into another

Hi Friends,

I have two input files

cat input1

chr1 100 200
chr1 200 300
chr2 300 400

cat input2

chr1 hello monday 10 20 . - . sometext
chr1 hello monday 20 30 . - . sometext
chr2 hello monday 30 40 . - . sometext

Now, I want to replace $1, $4 and $5 of input2 with $1, $2 and $3 of input1.

So, my final output would be

chr1 hello monday 100 200 . - . sometext
chr1 hello monday 200 300 . - . sometext
chr2 hello monday 300 400 . - . sometext

---------- Post updated at 10:07 AM ---------- Previous update was at 09:50 AM ----------

Thanks all.

I found the answer.

paste input2 input1 | awk '{print .....}'

Well, 'paste' is OK for identically keyed and sorted files, but 'join' is a more general solution (with sort to ensure it is key sorted, sometimes needing LC_ALL=C to make sort binary). Or awk could store one file in an associative vector and then look the right lines up to match with the lines of the second file, sort order not an issue but you need unique keys in file 1, as it a only a one to many join.