| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
Unix script
|
Original Message
|
Name: JJay
Date: March 7, 2005 at 08:31:45 Pacific
Subject: Unix scriptOS: UnixCPU/Ram: Unknown but high |
Comment: Guys, Using a script I need to grep thro' a file to search for a string then interrogate the next line to set if it contains another known string eg. File Name - Test.log contains the following lines :- Checking for file Process godown_jobid_0012 filemove done End process I need to grep for "jobid_0012" then check that the following line contains "filemove". If it does then flag success else flag fail. Any ideas??
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Jim Boothe
Date: March 7, 2005 at 10:20:22 Pacific
|
Reply: (edit)The first script is a bit simpler, exiting with proper status after checking the first occurrence of jobid_0012. The second script assumes that there may be multiple occurrences of jobid_0012, and it tries to find a success through the entire file. awk '/jobid_0012/ \ {getline if (index($0,"filemove")) exit 0 else exit 1}' infileawk '/jobid_0012/ { getline if (index($0,"filemove")) found=1} END { if (found==1) exit 0 else exit 1 }' infile
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Unix Forum Home