Help Need to fetch the required data

Hi Guys,

Am in need of your help one more time on my real data.
I have a file which contains more than thousand lines of data

Live data shown for 4 iterations. We have more than thousand lines of data:-
--------------------------------------------------------------------------

COM.ISEXTDC.PKGINIT:INIT
N
2013-09-12
12:54:45
1
cHitLast
APPS_MANAGEMENT
N
2013-09-12
21:14:19
18
cHitLast
APPS_MANAGEMENT:CLEARCLIENTQUEUE
N
2013-09-12
21:24:57
18
cHitLast
APPS_MANAGEMENT.CLEANUP:CLIENT
N
2013-09-12
20:14:18
3
cHitLast

--------------------------------
1) Need to check for every 6th line ( 'cHitLast') contains a value and it is greater than zero (o)
I dont want to print anything if the sixth line is other than numeric.
2) If the value is greater than 0 then need to print above 5 lines including the 6th line in the tabular format

Example:-

APPS_MANAGEMENT.CLEANUP:CLIENT
N
2013-09-12
20:14:18
3
5   ----> Here i have changed it to value 5 then the output should be as below:- 
 
Name       Prefetched       AccessLast               AccessTotal  Running
APPS...     N              2013-09-12 20:14:18           3              5

Thanks for your support in advance.

awk 'NR%6 {a=a"\t"$0;} NR%6==0 && $0+0>0 {a=a"\t"$0;sub(/\t/,"",a);print a;a=""} NR%6==0 {a=""}' file
APPS_MANAGEMENT.CLEANUP:CLIENT  N       2013-09-12      20:14:18        3       5

Hi Jotne,

Thanks for your response.
I am receiving the below error when I have executed the given code and nothing is getting logged in the log file.

awk: syntax error near line 1
awk: bailing out near line 1

awk 'NR%6 {a=a"\t"$0;} NR%6==0 && $0+0>0 {a=a"\t"$0;sub(/\t/,"",a);print a;a=""} NR%6==0 {a=""}'< $TEMP/memstat.out3 >> $TEMP/$SCRIPT.log

Try to run it manually from bash, not in script to see error.

awk 'NR%6 {a=a"\t"$0;} NR%6==0 && $0+0>0 {a=a"\t"$0;sub(/\t/,"",a);print a;a=""} NR%6==0 {a=""}' $TEMP/memstat.out3

Shorten some:

awk 'NR%6 {a=a?a"\t"$0:$0} NR%6==0 {if ($0+0) {a=a"\t"$0;print a}a=x}'  $TEMP/memstat.out3

If you are on solaris, use nawk

--ahamed