Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell scaning bunch of report and doing count.

Status
Not open for further replies.
Oct 22, 2001
215
US
Hi,
I got a report dir and under that I got different sub folder. The sub folders have diferent reports and all the report files have a return code value (0--10, 0 stands for no error). What I want to do is to scan all reports and count the error code by sub dir and finally display or email me the stat.

What would be the best way to go about this? Any sample code is appreciated. Thanks a lot!
Plz note I am using AIX and Kshell.
 
What have you so far ?
How the script is supposed to get the 'return code' from one report ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi PHV!
This 1 line get me the script name and the return code:
----------------------------
grep 'return code' * |more
----------------------------

The result looks like this:
dddd0208_01: *** RC (return code) = 0
rrrr0209_01: *** RC (return code) = 0
ssss0210_01: *** RC (return code) = 0
gggg0211_01: *** RC (return code) = 0

My problem is, I need to go to all sub folder and get the reports and scan for the above return codes and count them.
Can this be done?
Thanks
 
Something like this ?
grep 'return code' * */* | awk '{t+=$NF}END{print "Total="t}'

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
man awk

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top