hallo,
input file (cron log file with lines) - mixed lines like:
root : CMD ( /home/den/proc400.ksh >/dev/null ) : PID ( 18940110 ) : Tue Nov 6 21:30:00 2012
root : CMD ( /home/den/clean.ksh full >/dev/null ) : PID ( 53412070 ) : Tue Nov 6 23:30:00 2012
Cron Job with pid: 18940110 Failed
Cron Job with pid: 18943456 Successful
Cron Job with pid: 19535560 Successful
Cron Job with pid: 53412070 Failed
and want to find all tasks which exited with error (Failed status).
What i wanted to do is:
for i in `grep "^Cron Job with pid" log|awk '{print $5}'|sort -u`
do
awk -vx=$a '$(NF-7) == x || $(NF-1) == x {print}' log|sed 'N;s/\n/,/'|grep Failed$
done
and then join every two lines and grep for Failed.
The problem is that
$(NF-7) == x || $(NF-1) == x
is doesn't do what I expect. I want it to find all lines having the PID number ($a) on position $(NF-1) or $(NF-7). is it possible knowing that some lines have less fields then 7?