Re: Korn Shell Loop
From: Digger (hx_101_at_hotmail.com)
Date: 01/07/05
- Next message: Nick Sinclair: "cron script hangs after a while (seems to)"
- Previous message: Ed Morton: "Re: Korn Shell Loop"
- In reply to: Ed Morton: "Re: Korn Shell Loop"
- Next in thread: Ed Morton: "Re: Korn Shell Loop"
- Reply: Ed Morton: "Re: Korn Shell Loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 06 Jan 2005 21:48:41 -0500
How is this going to extract it from the file???
On Thu, 06 Jan 2005 20:29:50 -0600, Ed Morton <morton@lsupcaemnt.com>
wrote:
>
>
>Digger wrote:
>> I was trying this but couldn't get it to work.....
>>
>> awk '
>> /ERROR/ { URL[$3] = $0 };
>> /CLEAR/ { delete URL[$3] };
>> END {
>> for ( urls in URL ) {
>> print URL[$3]
>
>ITYM:
>
> print URL[urls]
>
>> }' url.log > error.log
>
>The above logic would print out all URLs that have an ERROR indication
>but no subsequent CLEAR which isn't what you described elsethread. You
>described this:
>
> "Search the log file until you find "ERROR" and get the URL.
>
> From this point in the log file find the next occurance of the SAME
> URL with the OK status.
>
> If not found
>
> return 1
> exit
> or else return 0."
>
>so if that's what you really want, try this (untested):
>
>awk '!badUrl && /ERROR/ {badUrl = $3; found = 1}
> $3 == badUrl && /CLEAR/ {found = 0; exit}
> END{ exit(found) }'
>
>Regards,
>
> Ed.
>
>> On Thu, 06 Jan 2005 16:41:43 -0600, Ed Morton <morton@lsupcaemnt.com>
>> wrote:
>>
>>
>>>
>>>Digger wrote:
>>>
>>>
>>>>I am trying to code a simple loop that will read a log file and
>>>>extract out a url that has an error. Then with that url, scan the rest
>>>>of the file (end of file) to see if that same url occurs again but
>>>>with a success message. If is does find the success flag return a 0 to
>>>>a file, if not return 1 to the file....
>>>>
>>>>Is this possible with ksh?
>>>
>>>Yes, and with any other shell. You can also do it in awk or perl. Show
>>>us a SMALL sample input, expected output, and at least some pseudo-code
>>>for more help.
>>>
>>> Ed.
>>>
>>>
>>>>Thanks
>>
>>
- Next message: Nick Sinclair: "cron script hangs after a while (seems to)"
- Previous message: Ed Morton: "Re: Korn Shell Loop"
- In reply to: Ed Morton: "Re: Korn Shell Loop"
- Next in thread: Ed Morton: "Re: Korn Shell Loop"
- Reply: Ed Morton: "Re: Korn Shell Loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|