I have a requirement to process number of files matching a criteria. The resulted file would be processed indivdually looking for a particular string until another one found lines afterwards. Then look for the occurrence of another string in the result count and display/return the result.
Continue the process till the EOF reached then to take the next file do the same ... till no more files to process
So all I wanted to know is how many occaurcnce of </item> in this log file after "######### AUD57#########" and between "</:_:REQUESTSTRUCTURE>"
I have a kind of script which does this but takes ages to result (with process line by line). so would like to see a simpler and much faster solution - HELP please URGENT
nawk '
/######### AUD57#########/{a++}
/<\/ITEM>/{items[a]++}
END{
for( i in items ){
print "No of items in AUD57("i") is - "items
t += items
}
print "Total items in file = "t
}
' infile
ofcourse you could do that but there are other audit entries like
#####====> AUD99 - ACTION
<:RequestStructure>
</item>
</item>
</item>
</:RequestStructure>
Thanks a lot for the time and effort. That would work exactly if the input log file looks like that. but as I said earlier the <item> can be random in between and some are not even inside a "AUDxx" block.
In the example log if you have an <item> floating (with out having proper AUD and Requeststructure then the script would result 10 - wouldnt? . And that's the problem for me. Sorry I know this is getting longer.
I start thinking to write a java program to sort this out as I have very little time left on this.