Sponsored Content
Top Forums Shell Programming and Scripting Extracting text between two patterns 1 and 2 and pattern2 should be second occurrence of the file Post 302547838 by gangii87 on Wednesday 17th of August 2011 04:05:16 PM
Old 08-17-2011
Hi
Please find the exact logs below

logs:
29-Jul-2011 08:48:22,653 GMT Static data requires update
serverID=fxValue,CancelTimestamp=0,createdTimestamp=1311925697809,lastUpdatedBy=null,revision=0]
Location=London,Name=IBM London Operation Vincenzo Maini,cancelReason=null,ndf=false,
29-Jul-2011 08:48:23,653 GMT Static data requires update
serverID=fxValue,CancelTimestamp=0,createdTimestamp=6311925697809,lastUpdatedBy=null,revision=0]
Location=London,Name=IBM London Operation Vincenzo Maini,cancelReason=null,ndf=false,
createdByUserId=sam@gmail.com
------------------------
-------------------------
-------------------------
-------------------------
29-Jul-2011 08:48:24,653 serverID=fxValue,CancelTimestamp=0,createdTimestamp=8311925697809, lastUpdatedBy=null,revision=0] Location=London,Name=IBM London Operation Vincenzo Ludovico Maini,cancelReason=null,ndf=false,book=LEMFXAUT, createdByUserId=sam@gmail.com


In the above logs my search pattern will be 08:48:22 and UserId=sam@gmail.com

---------- Post updated 08-17-11 at 03:05 PM ---------- Previous update was 08-16-11 at 04:38 PM ----------

Hi All,
I finally got the logic by reading few older posts in this site
really this site is very helpful for the beginners like me

Here is working logic
awk '
BEGIN { start=0; skip=0; }
{
if(index($0, "08:48:22")> 0)
{start=1; print $0}
else
if(index($0, "sam@gmail.com")> 0) { if(skip==0) skip=1; else {skip=0; start=0; print$0 }}
else
if(start==1)
{
print $0
}
} ' log

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete string in a text file leaving the first occurrence

Hi, How can i delete the second and subsequent occurrence of a particular string from a file ? eg) test.txt cattle bat battle mat matter cattle cattle my output file should be cattle bat battle mat matter (12 Replies)
Discussion started by: gopskrish
12 Replies

2. Shell Programming and Scripting

Getting the lines between last occurrence of two patterns

Hi I am new shell scripting, i need help on the follwoing I have a application log file, the application is called on cron, the log includes a "started" and "finished" lines repeatedly. I need to get the log of the for the latest run of the application. Sample log file Started adfa fadfa... (8 Replies)
Discussion started by: rvz
8 Replies

3. Shell Programming and Scripting

Sed Help.To Search Between Pattern1 And Pattern2 Containing Certain Text

Hi, Here is a sample of my Test File $ cat TestFile1 Prompt Table DQZ_ALTER_SCHEMA_ID; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID MONITORING; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID STORAGE ( NEXT 3464K ); Prompt Table DQZ_ALTER_SCHEMA_ID; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID MOVE LOB... (16 Replies)
Discussion started by: rajan_san
16 Replies

4. UNIX for Dummies Questions & Answers

Locating and Extracting Specific Patterns from a file

Hi all, 1. I have a file that is getting continously refreshed (appended) I want to grep all the strings containing substring of the type abcdf123@aaa.xxx.yyy.zzz:portnumber: where, before @, any letters or numbers combination, after @, IP address then symbol : then port... (4 Replies)
Discussion started by: kokoras
4 Replies

5. Shell Programming and Scripting

Sed/awk print between different patterns the first occurrence

Thanks for the help yesterday. I have a little modification today, I am trying the following: i have a log file of a webbap which logs in the following pattern: 2011-08-14 21:10:04,535 blablabla ERROR Exception1 blablabla bla bla bla bla 2011-08-14... (2 Replies)
Discussion started by: ppolianidis
2 Replies

6. Shell Programming and Scripting

[Solved] Sed/awk print between patterns the first occurrence

Guys, I am trying the following: i have a log file of a webbap which logs in the following pattern: 2011-08-14 21:10:04,535 blablabla ERROR blablabla bla bla bla bla 2011-08-14 21:10:04,535 blablabla ERROR blablabla bla bla bla ... (6 Replies)
Discussion started by: ppolianidis
6 Replies

7. Shell Programming and Scripting

Append text to line if begins with pattern1 AND does not end with pattern2

Hello, I'm looking for sed solution to change ... <li>keyword</li> <li>keyword <li>keyword</li> <li>keyword <li>keyword</li> ... to ... <li>keyword</li> <li>keyword</li> <li>keyword</li> <li>keyword</li> <li>keyword</li> ... I.e., if lines beginning with <li> do not end with... (3 Replies)
Discussion started by: pioavi
3 Replies

8. Shell Programming and Scripting

Extracting a set of patterns from the text file

Hi experts, I need a help in extracting a set of patterns from the text file. Below is my scenario. Input file: I need to extract the data between My output should be as Thanks, Kalai (7 Replies)
Discussion started by: kalpeer
7 Replies

9. Shell Programming and Scripting

Adding text to the end of the specific line in a file(only to the first occurrence of it)

Hi, I want to add a text to the end of the specific line in a file. Now my file looks like this: 999 111 222 333 111 444 I want to add the string " 555" to the end of the first line contaning 111. Moreover, I want to insert a newline after this line containg the "000" string. The... (8 Replies)
Discussion started by: wenclu
8 Replies

10. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies
KML2GMT(1gmt)						       Generic Mapping Tools						     KML2GMT(1gmt)

NAME
kml2gmt - Extract GMT table data from Google Earth KML files SYNOPSIS
kml2gmt [ infile ] [ -V ] [ -Z ] [ -:[i|o] ] [ -bo[s|S|d|D[ncol]|c[var1/...]] ] DESCRIPTION
kml2gmt reads a Google Earth KML file and outputs a GMT table file. Only KML files that contain points, lines, or polygons can be pro- cessed. This is a bare-bones operation that aims to extract coordinates and possibly the name and description tags of each feature. The main use intended is to capture coordinates modified in Google Earth and then reinsert the modified data into the original GMT data file. For a more complete reformatting, consider using ogr2ogr -f "GMT" somefile.gmt somefile.kml. infile Name of the KML file to work on. If not given, standard input is read. OPTIONS
No space between the option flag and the associated arguments. -Z Output the altitude coordinates as GMT z coordinates [Default will output just longitude and latitude]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -: Toggles between (longitude,latitude) and (latitude,longitude) input and/or output. [Default is (longitude,latitude)]. Append i to select input only or o to select output only. [Default affects both]. -bo Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of desired columns in your binary output file. EXAMPLES
SEE ALSO
gmtdefaults(1), GMT(1), img2google(1), ps2raster(1) gmt2kml(1) GMT 4.5.7 15 Jul 2011 KML2GMT(1gmt)
All times are GMT -4. The time now is 08:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy