Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for a sequence then print between two postions

Status
Not open for further replies.

jdespres

MIS
Aug 4, 1999
230
US
I would like to search for the following ::---> "open file:"

Then once found print whatever is between the following...

"open file:" <------- Print whatever -------> "(WIN32 32:"

I have tried the following:
bperror | grep -i "open file:" |awk '/"open file"/,/"\(WIN32"/ {print}'

bperror | grep -i "open file:" |awk '/"open file"/,/"\(WIN32"/ {print}'

Both of these didn't work...

Thanks

Joe Despres
 
Hi

Joe said:
bperror | grep -i "open file:" |awk '/"open file"/,/"\(WIN32"/ {print}'
You are [tt]grep[/tt]ing out only the lines containing "open file:", then you are expecting that [tt]awk[/tt] will also find lines containing "(WIN32" ? That can not work. Remove the piping through [tt]grep[/tt] :
Code:
bperror | awk '/open file/,/\(WIN32/'
Joe said:
Both of these didn't work...
Those two are literally identical. You did something wrong when copy & pasting the code.

Feherke.
 
You wanted something like this ?
Code:
bperror | awk '/open file:/{sub(/.*open file:/,"");sub(/\(WIN32 32:.*/,"");print;exit}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
it's close.....

I get one line of data... should be alot...

I removed the exit..... And it worked....

I forgot I needed to also print out whats at column $13

Thanks....

Joe Despres
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top