Please help in creating search script

Hi all,

Hope everyone is doing fine. I need a help in creating search script. I have file which contains job names and job recs. I need to select specific job name and next line which is job rec

 job (BLREEXTT) {
     Record B${cycle}${month}${year}000075;
     follows BLCYRRTCHKT;
     HOST BL_HOST ; }
 job (BLPIEXTT) {
     Record B${cycle}${month}${year}000075;
     follows BLPIHNDLT,BLCYRRTCHKT;
     HOST BL_HOST ; }
 job (BLSRVAGREXTT) {
     Record B${cycle}${month}${year}${paralleltitanbl}0075;
     follows BLCYRRTT;
     HOST BL_HOST ; }

So basicaly file contains many enteries like this. I need to select (in bold ) job which is an easy part and next line. I can grep for job, but how to select line after that. Note that 000075 is changing in the file.

If you are on Linux then this should work:

grep -A1 "BLPIEXTT" file

Thanks for the fast reply
I'm using Unix but not sure which version.
grep: illegal option -- A
So I'm assuming that I can't use -A on my version

Check on what system you are with:

uname -a

(post the output here). Anyway this might work on your Unix:

awk '/BLPIEXTT/{print;getline;print}' file
1 Like

For this simple scenario, a bit of sed:

$ sed -n "/BLPIEXTT/{N;p;}" file
 job (BLPIEXTT) {
     Record B${cycle}${month}${year}000075;

(works on Solaris 8 - so should work everywhere!!)

1 Like

One more time,

Thanks guys you saved me a bunch of time. Very appriciate it!!!!

We can close this disccusion, not really sure how to do it.