BEGIN{ isd=0; epsum=0; npts=0 } /Molecular dynamics:/{ while( $1 != "nstlim") getline; split($3,a,","); nstlim = a[1]; } /DV\/DL,/{ isd=1} /NSTEP/{ if(isd == 1 ){nstep = $3 ; tim = $6; }} /EPtot/ { if(isd == 1 ) { if( nstep >= nstart ) { npts += 1; eptot = $9; epsum = epsum + $9; print tim,eptot,epsum/npts ; } isd = 0; } }