Hi guys,
FILE1 : Is the output of a command which contains data something like this in a single line.
Now the contents of the file2 are the links corresponding to each of the paths highlighted above, There will be exactly same number of links in file2 in the same order as the number of paths in file1.Code:------------------------------------------------------------------------ r201463 | ngupta@gmail.com | 2012-06-19 22:02:20 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/me/MBSF.java Text is cutting code ------------------------------------------------------------------------ r201464 | ngupta@gmail.com | 2012-06-19 22:04:05 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/FTC.java M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/RTC.java M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/TC.java Text is cut from above ------------------------------------------------------------------------ r201500 | ss@gmail.com | 2012-06-20 17:23:33 +0530 (Wed, 20 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/client/src/ve/mb.ve b.ve ------------------------------------------------------------------------ r201535 | asaini@gmail.com | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/de/RL.java Pending Contact Count issue ------------------------------------------------------------------------ r201572 | ngupta@gmail.com | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/res/mb/res.xml message invalid pin. ------------------------------------------------------------------------ r201575 | ngupta@gmail.com | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/mb/MBSF.java check ------------------------------------------------------------------------
The problem i need to solve is that i need to place the links of the file2 exactly at the end of the corresponding paths of file1 or may be at the end of the line that contains the path just before this pattern "-------", The output will be as shown,Code:URL1 xyz/cdd/ddf/fff/MBSF.javaURL2 xyz/cdd/ddf/fff/FTC.java URL3 xyz/cdd/ddf/fff/RTC.java URL4 xyz/cdd/ddf/fff/TC.java URL5 xyz/cdd/ddf/fff/mb.ve b.ve URL6 xyz/cdd/ddf/fff/RL.java URL7 xyz/cdd/ddf/fff/res.xml URL8 xyz/cdd/ddf/fff/MBSF.java
The output i need,
As one can see the contents of file1 is as above and is stored in a single line.Code:------------------------------------------------------------------------ r201463 | ngupta@gmail.com | 2012-06-19 22:02:20 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/me/MBSF.java Text is cutting code URL1 xyz/cdd/ddf/fff/MBSF.java------------------------------------------------------------------------ r201464 | ngupta@gmail.com | 2012-06-19 22:04:05 +0530 (Tue, 19 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/FTC.java M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/RTC.java M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/ci/TC.java Text is cut from above URL2 xyz/cdd/ddf/fff/FTC.java URL3 xyz/cdd/ddf/fff/RTC.java URL4 xyz/cdd/ddf/fff/TC.java------------------------------------------------------------------------ r201500 | ss@gmail.com | 2012-06-20 17:23:33 +0530 (Wed, 20 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/client/src/ve/mb.ve b.ve URL5 xyz/cdd/ddf/fff/mb.ve b.ve------------------------------------------------------------------------ r201535 | asaini@gmail.com | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/de/RL.java Pending Contact Count issue URL6 xyz/cdd/ddf/fff/RL.java------------------------------------------------------------------------ r201572 | ngupta@gmail.com | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/res/mb/res.xml message invalid pin. URL7 xyz/cdd/ddf/fff/res.xml ------------------------------------------------------------------------ r201575 | ngupta@gmail.com | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /client/j2me/cc/es/v0/luc/src/main/java/com/airone/cclient/mb/MBSF.java check URL8 xyz/cdd/ddf/fff/MBSF.java------------------------------------------------------------------------
Please observe the highlighted part.
The red colored paths are placed in single lines in between the "-------" pattern.
Whereas the cream colored paths (3) are placed in multiple lines in between the "--------" pattern.
Now initially the problem was solved using this code
This code works fine if the cream colored paths was a single path.Code:awk 'BEGIN{while(getline v <"file2"){sub("[^ ]* ","",v); c[++n]=v}}{split($0,a," "); split($0,b," "a[1]); for(i in b)if(b[i])printf("%s %s ", i==1?b[i]:a[1]b[i],c[i]);print a[1]}' file1
That is if the path in between the pattern "-----" is single then the above code works fine.
But if there are multiple paths between each pattern "-----" then the alignment of the links get jumbled.
I hope i have explained the problem clearly.
Since i am a newbie to awk i am reaching out to u ppl for the help.
Thanks,
Kashyap.

Reply With Quote