IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New how to do this
I have an error log that contains the following
timestamp : App id : message content: messageID
timestamp : App id : message content: messageID
timestamp : App id : message content: messageID
timestamp : App id
<xml tagged message>
timestamp : App id : message content: messageID
timestamp : App id : message content: messageID
timestamp : App id : message content: messageID

what I need is the timestamp and xml tagged message of certain messages. When I use grep to find the message all I can think of is ugly hacks involving line numbering to go back up one line to retrieve the timestamp. Any suggestions?
thanx,
bill
when I was young I envisioned myself as the embodiment of Trinity, Now I realize I have turned into the Bambino
questions, help? [link|mailto:pappas@catholic.org|email pappas at catholic.org]
New Re: how to do this
Look for the lines that have only one colon in them, then start parsing the xml message following; when you reach the final close tag, start looking for lines that have only one colon in them again.
--\n-------------------------------------------------------------------\n* Jack Troughton                            jake at consultron.ca *\n* [link|http://consultron.ca|http://consultron.ca]                   [link|irc://irc.ecomstation.ca|irc://irc.ecomstation.ca] *\n* Kingston Ontario Canada               [link|news://news.consultron.ca|news://news.consultron.ca] *\n-------------------------------------------------------------------
New Re: how to do this
In Perl, you could set the record separator ($/)to something like "timestamp:" and read the records in, searching for what you want.

I've got to dash out now, so don't have time to have a stab at it, but perhaps someone else will either tell me I'm a buffoon for suggesting this or show how it's done :)


Peter
[link|http://www.debian.org|Shill For Hire]
[link|http://www.kuro5hin.org|There is no K5 Cabal]
[link|http://guildenstern.dyndns.org|Home Page - Now with added Zing!]
New No code - context grep
grep -B 2 "stuff_you_are_looking_for" file.name

\n-B NUM, --before-context=NUM\nPrint  NUM  lines  of  leading  context  before  matching lines.\nPlaces  a  line  containing  --  between  contiguous  groups  of\nmatches.\n


Or is the number of lines variable?

In that case:

\n#!/usr/bin/perl -w\nuse strict;\n\nmy $look_for = shift;\n\nmy $last_time_stamp = '';\nmy @current_xml = ();\n\nwhile (<>){\n\n#\n# I need a REAL exmaple of the time stamp line!!\n# Pretend it is MMDDYY : Stuff\n#\nif (/^\\d{6}\\s:/){\n$last_time_stamp = $_;\n@current_xml = ();\nnext;\n}\npush (@current_xml, $_);\n\nif (/$look_for/){\nprint "Found it: [$look_for]\\n";\nprint "$last_time_stamp\\n";\nprint join("\\n",@current_xml),"\\n";\n}\n\n}\n



LRPD:
Somewhere out there, a Big Cheetah is still running WordStar and extremely anal benchmarks...

No it's not:
[link|http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&safe=off&c2coff=1&q=%22big+cheetah%22+pournelle&btnG=Google+Search|http://www.google.co...tnG=Google+Search]

Retired in 1996

I've realized the LRPDs are the ultimite"in" jokes.
Expand Edited by broomberg March 5, 2004, 07:51:01 PM EST
New gah, man grep would have got it :(
forget there is a crapload of flags, my bad for not looking it up
thanx a bunch,
bill
when I was young I envisioned myself as the embodiment of Trinity, Now I realize I have turned into the Bambino
questions, help? [link|mailto:pappas@catholic.org|email pappas at catholic.org]
     how to do this - (boxley) - (4)
         Re: how to do this - (jake123)
         Re: how to do this - (pwhysall)
         No code - context grep - (broomberg) - (1)
             gah, man grep would have got it :( - (boxley)

Can bitching and moaning atone?
96 ms