Content merging at a specific location in a file

Hi,

This is a bit lengthy problem, i will try to keep explaining it simple.

I have got a file say file1 that contains the following in it,

------------------------------------------------------------------------ r201463 | ngupta@gmail.com | 2012-06-19 22:02:20 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/mb/MBF.java  we press enter key in keypad ------------------------------------------------------------------------ r201464 | ngupta@gmail.com | 2012-06-19 22:04:05 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/cvcui/FTC.java M /client/cvcui/RC.java M /client/cvcui/TC.java Screen is cut from above ------------------------------------------------------------------------ r201500 | ssank@gmail.com | 2012-06-20 17:23:33 +0530 (Wed, 20 Jun 2012) | 1 line Changed paths: M /client/mb.ven Cv/mb.ven ------------------------------------------------------------------------ r201535 | asaini@gmail.com | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/db/RL.java  b3410 ------------------------------------------------------------------------ r201572 | ngupta@gmail.com | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/mb/res.xml  invalid pin. ------------------------------------------------------------------------ r201575 | ngupta@gmail.com | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/mb/MBSF.java  UI changes ------------------------------------------------------------------------

Now i have another file say file2

URL1 xyz/cdd/ddf/client/mb/MBF.java
URL2 xyz/cdd/ddf/client/cvcui/FTC.java
URl3 xyz/cdd/ddf/client/cvcui/RC.java
URL4 xyz/cdd/ddf/client/cvcui/TC.java
URL5 xyz/cdd/ddf/client/mb.ven
URL6 xyz/cdd/ddf/client/db/RL.java
URL7 xyz/cdd/ddf/client/mb/res.xml
URL8 xyz/cdd/ddf/client/mb/MBSF.java

The problem i am facing is i want the links of file 2 to be placed next to the corresponding paths of file1.

The final output i need is as below,

------------------------------------------------------------------------ r201463 | ngupta@gmail.com | 2012-06-19 22:02:20 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/mb/MBF.java URL1 xyz/cdd/ddf/client/mb/MBF.java we press enter key in keypad ------------------------------------------------------------------------ r201464 | ngupta@gmail.com | 2012-06-19 22:04:05 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/cvcui/FTC.java URL2 xyz/cdd/ddf/client/cvcui/FTC.java M /client/cvcui/RC.java URl3 xyz/cdd/ddf/client/cvcui/RC.java M /client/cvcui/TC.java URL4 xyz/cdd/ddf/client/cvcui/TC.java Screen is cut from above ------------------------------------------------------------------------ r201500 | ssank@gmail.com | 2012-06-20 17:23:33 +0530 (Wed, 20 Jun 2012) | 1 line Changed paths: M /client/mb.ven URL5 xyz/cdd/ddf/client/mb.ven Cv/mb.ven ------------------------------------------------------------------------ r201535 | asaini@gmail.com | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/db/RL.java URL6 xyz/cdd/ddf/client/db/RL.java  b3410 ------------------------------------------------------------------------ r201572 | ngupta@gmail.com | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/mb/res.xml URL7 xyz/cdd/ddf/client/mb/res.xml invalid pin. ------------------------------------------------------------------------ r201575 | ngupta@gmail.com | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/mb/MBSF.java URL8 xyz/cdd/ddf/client/mb/MBSF.java UI changes ------------------------------------------------------------------------

I hope i have explained the problem.
Please do help me to accomplish this task as i am a newbie to unix.
Thanks,
Manju.

As you did not specify how to identify the part-URL from file1 in file2,I based it on char position. This may need to be corrected/adapted:

$ awk 'NR==FNR{Ar[$0]++;next} {for (x in Ar) gsub (substr(x,18), substr(x, 18)" "x)}1' file2 file1

Pls test and come back with results.

Hi rudic,
Thanks for the reply.
There is no change in the output,
I mean its not inserting the URLs' .

It does on my linux/nawk system, I compared it to your desired output and it fitted. What system are you on? You may need to run a different version of awk.