Replacing strings

Hello All,
I have two files with delimited |

file 1 :
1|2|3
11|12|13
22|23|24

and file 2 :
1|4|5|6
11|14|15|16
22|25|26

I want to replace the value '1' in file 2 with the values in file 1 '1|2|3'

so the final output will look like

1|2|3|4|5|6
11|12|13|14|15|16
22|23|24|25|26

any suggestions how I do this in bash shell ?

Please use code tags as required by forum rules!

Any attempts from your side?

---------- Post updated at 12:53 ---------- Previous update was at 12:52 ----------

Howsoever, try

awk 'NR==FNR {T[$1]=$0; sub($1 "\\" FS, "", T[$1]); next} {print $0, T[$1]}' FS="|" OFS="|" file2 file1
1|2|3|4|5|6
11|12|13|14|15|16
22|23|24|25|26

Hello Arun,

Following may help you in same.

awk -F"|" 'FNR==NR{A[$1]=$NF;next} ($1 in A){B=$1;C=A[$1];while(B <= C){O=O?O FS B:B;B++};print O;O=""}' OFS="|" file2 file1
 

Output will be as follows.

1|2|3|4|5|6
11|12|13|14|15|16
22|23|24|25|26
 

Thanks,
R. Singh

join -t"|" file1 file2