![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extracting Text | krabu | Shell Programming and Scripting | 3 | 04-07-2009 04:16 AM |
| extracting text and reusing the text to rename file | JohnDS | UNIX for Dummies Questions & Answers | 7 | 02-05-2009 03:55 AM |
| Extracting information from Config files /text processing | oconmx | Shell Programming and Scripting | 3 | 01-21-2009 07:09 PM |
| help required for replacing text in vi | Chandu2u | Shell Programming and Scripting | 6 | 01-26-2008 11:12 AM |
| Help required regarding Extracting lines from a file | google_ever | Shell Programming and Scripting | 1 | 10-12-2005 08:02 AM |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Extracting the required text from log files
It would be highly appreciable if any one helps me in this. I am trying to get it done through Java but I love unix and believe it can be done within minutes with couple of lines.
The input log file is a text file contains multiple entries seperated by a blank line. Each seperated entry corresponds to upgrade process information of one file. !ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test.java> 2009-06-18 13:01:01.181 !MESSAGE Requesting upgrade report for file: test.java !ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test1.java> 2009-06-18 13:01:01.181 !MESSAGE information in test1.java will be upgraded. !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: full path /file name> 2009-06-18 13:02:25.681 !MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support. Each Entry starts with "!ENTRY" as shown above and will be followed by text "com.bea.workshop.upgrade81 " and then it will be followed by two types of tags: <OKAY> and <INFO> And then it will be followed by tag <RESOURCE:which contains the full path of the file and then followed by time stamp as shown above. If it is <OKAY>, then second line will be as below !MESSAGE Requesting upgrade report for file: filename ( Which is not of much importance for my output) Ex: !ENTRY text.....<INFO> or <OKAY> <RESOURCE: /test/src/com/test1/*/test.java> 2009-06-18 13:01:01.181 !MESSAGE Requesting upgrade report for file: file name If it is <INFO> then also second line will be like !MESSAGE Requesting upgrade report for file: filename But it will certainly be followed by another set of multiple line pairs starting with tags !SUBENTRY,!MESSAGE like below !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: path/filename> 2009-06-18 13:02:25.681 !MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support. My requirement is like below: Requirement 1 1) For all entries containing <OKAY> tag, I need to extract the file names which will be after <RESOURCE:.....and before time stamp Please note the entries are seperated by a blank line Requirement 2 2) For all the lines with <INFO> tag, I would like to have a text file with entries like this Full path and the file name and then in the next line All the text after !MESAAGE right below the line containg the tag of corresponding "!SUBENTRY 1" tags Example Input: ============================== !ENTRY com.bea.workshop.upgrade81 <OKAY> <RESOURCE: /fullpathr/Test.java> 2009-06-18 13:02:28.368 !MESSAGE Requesting upgrade report for file: Test.java !ENTRY com.bea.workshop.upgrade81 <OKAY> <RESOURCE: /fullpath/Test1.jpf> 2009-06-18 13:02:28.384 !MESSAGE Requesting upgrade report for file: Test1.jpf !ENTRY com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447 !MESSAGE Requesting upgrade report for file: Test2.jpf !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447 !MESSAGE The Java 5 annotation Jpf.Controller needs to be added. !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test2.jpf> 2009-06-18 13:02:28.447 !MESSAGE More annotation of Jpf.Action needs to be added. !ENTRY com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634 !MESSAGE Requesting upgrade report for file: Test3.jpf !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634 !MESSAGE The Java 5 annotation Jpf.Controller needs to be added. !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634 !MESSAGE Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support. !SUBENTRY 1 com.bea.workshop.upgrade81 <INFO> <RESOURCE: /fullpath/Test3.jpf> 2009-06-18 13:02:28.634 !MESSAGE ABC needs to be added. Output for requirement1: ================================ Test.java Test1.jpf Output for requirement2: ================================ /fullpath/Test2.jpf The Java 5 annotation Jpf.Controller needs to be added. More annotation of Jpf.Action needs to be added. /fullpath/Test3.jpf The Java 5 annotation Jpf.Controller needs to be added. Will add import of org.apache.beehive.netui.pageflow.annotations.Jpf for JPF annotation support. ABC needs to be added. Last edited by hareeshram; 06-20-2009 at 10:09 AM.. |
| Bookmarks |
| Tags |
| log extract |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|