INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

looking for lines...

looking for lines...

(OP)

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?

RE: looking for lines...

Hi

Possible to misunderstood the requirement, as you posted no sample of expected output. This is based on the "join every two lines and grep for Failed" part :

CODE --> command-line

awk 'NF>10&&$(NF-9)=="PID"{p[$(NF-7)]=$0;next}$NF=="Failed"{print p[$(NF-1)],$0}' /input/file 
Tested with gawk and mawk.

Feherke.
http://feherke.github.com/

RE: looking for lines...

(OP)
you simply got it right winky smile

thank you!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close