awk how to search strings within a file from two different lines

Hi, i would really appreciate any help anyone can give with the following info.

Thanks in advance.

I need to run a search on a file that contains thousands of trades, each trade is added into the file in blocks of 25 lines. i know the search has to take place between a time stamp specified and ends with a greater than character ">", i then need to search for two strings of digits held within the 25 lines on different lines and then set these up as variables so i can calculate the % of VAR1 to VAR2.

I've managed to get the script to work by running a read to set the time and ">" and then use the variables as my awk search string /$TIME/,/^\>/
but i'm then piping to awk and sed mulitple times which makes it look messy to gain the variable figures. (Will try to cut/paste the script in tomorrow at work)

Example of the file (underlined the search string and variables)

2011-06-05 23:04:43 data time stamp file setting
proc(1) in(34) ty(55)
ft(67) tg(56) fg(67) fd(78)
fg(67) fg(89) df(67) Tot(100)
fg(87) fg(ty) ina(67)
pre(89) fg(43) (ui) gh(45) 
rf(89) f(rt) ina(34)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Change the awk record separator so it is one record.

Sorry i have no idea what that is suppose to mean ?

You can use the ">>>>>" as record separator, like this:

awk 'BEGIN{RS=">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; FS="\n"} {print $2}' infile

proc(1) in(34) ty(55)

1 Like

A hint should be sufficient to learn to fish: awk change record separator tutorial - Google Search