how to awk a data from seperate lines

Hi guys,

i have a problem which im hoping you will be able to help me with.

I have follwing output :-
-------------------------------------------------------------------------------
NSTEP = 407000 TIME(PS) = 43059.000 TEMP(K) = 288.46 PRESS = 0.0
Etot = -2077.4322 EKtot = 1259.9293 EPtot = -3337.3615
BOND = 354.7187 ANGLE = 793.3348 DIHED = 1116.0273
1-4 NB = 372.9656 1-4 EEL = 3636.2281 VDWAALS = -773.6836
EELEC = -5974.4091 EGB = -2898.5317 RESTRAINT = 0.0000
ESURF= 35.9885
------------------------------------------------------------------------------
NSTEP = 407500 TIME(PS) = 43060.000 TEMP(K) = 297.19 PRESS = 0.0
Etot = -2058.5407 EKtot = 1298.0826 EPtot = -3356.6233
BOND = 338.0366 ANGLE = 797.3124 DIHED = 1103.4133
1-4 NB = 375.9714 1-4 EEL = 3627.9377 VDWAALS = -788.2402
EELEC = -6205.8471 EGB = -2642.2325 RESTRAINT = 0.0000
ESURF= 37.0250
------------------------------------------------------------------------------

what i would like to do is extract the value TIME and ETOT. How can i do this with awk? im not great with awk so i dont know how to search for two different fields in one command, im sure there must be a way thou.

so far, ive been extracting each field seperatly using the following command:-

grep TEMP filename | awk '{print $6}' > time.dat

and then i would cut and paste each field in gedit.... however this is silly work around and id appreciate if someone could direct me to a better alternative.

Cheers

Mish

cut and paste the fields in nedit.

This should be one way:

 awk '/TIME/{a=$6}/Etot/{print a, $3}' file > new_file

Seems to do the trick, will save me lots of time.
Thank you very much

Mish