|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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, Code:
------------------------------------------------------------------------ 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 Code:
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, Code:
------------------------------------------------------------------------ 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. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
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: Code:
$ awk 'NR==FNR{Ar[$0]++;next} {for (x in Ar) gsub (substr(x,18), substr(x, 18)" "x)}1' file2 file1Pls test and come back with results. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi rudic,
Thanks for the reply. There is no change in the output, I mean its not inserting the URLs' . |
|
#4
|
|||
|
|||
|
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.
|
| Sponsored Links | ||
|
![]() |
| Tags |
| sathyaonunix |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| merging of 2 consecutive lines in a file for a specific pattern | novice_man | Shell Programming and Scripting | 1 | 12-15-2010 12:47 AM |
| Bash copy file contents into an existing file at a specific location | gshepherd7 | Shell Programming and Scripting | 6 | 03-11-2009 09:26 AM |
| Insert 2 lines in a file at a specific location | potro | Shell Programming and Scripting | 2 | 05-08-2008 07:38 PM |
| Remove duplicates from File from specific location | gopikgunda | Shell Programming and Scripting | 1 | 04-09-2008 02:16 AM |
| Insert lines at specific location in file | hcclnoodles | Shell Programming and Scripting | 17 | 03-28-2007 08:00 AM |
|
|