Re: Korn Shell Loop

From: Digger (hx_101_at_hotmail.com)
Date: 01/07/05


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
>>
>>



Relevant Pages

  • Re: Korn Shell Loop
    ... Digger wrote: ... > How is this going to extract it from the file??? ... >> From this point in the log file find the next occurance of the SAME ...
    (comp.unix.shell)
  • Re: Extract the whole column in a file
    ... Using AWK, how can I extract a set of columns based on header ... With the following embedded test data in the here document and the ...
    (comp.unix.shell)
  • Re: Extract the whole column in a file
    ... how can I extract a set of columns based on header ... I assume you want an arbitrarily choosen set of columns in every call. ... subsequent awk program... ... as I have to extract column info for many columns. ...
    (comp.unix.shell)
  • Re: using case to check boundary in number range
    ... Chris F.A. Johnson wrote: ... >>the file to extract the total number of lines using awk. ...
    (comp.unix.shell)
  • Re: problem with spaces in quoted string arguments
    ... I am passing a list of file records to awk in an attempt to extract ... I simply cat the file into gawk and I was hoping to extract the name ... As can be seen in the output, the server called "photon hub" did not ... since the space was detected in the argument to awk. ...
    (comp.unix.shell)