I have these lines repeating
FINAL RESULTS
NSTEP ENERGY RMS GMAX NAME NUMBER
1000 -4.7910E+01 2.1328E-01 9.4193E-01 C 62
The FINAL RESULTS indicate a average of those values for a set. The output file combines all 1000 sets. I need to grab the number below energy (-4.7910E+01), all 1000 of them in to another file. I need to set FINAL RESULTS as a pattern because other pattern such as NSTEP, ENERGY, RMS.... are repeated in millions.
I'll be grateful for any help.
Something like this should work for you:
awk '/FINAL RESULTS/{for (i=0; i<5; i++) getline; print $2}' <filename>
OK, I think I see now.
awk 'found==1 { print $2; found=0 } $2=="ENERGY" { found=1 }' inputfile
This will get the number below ENERGY regardless of how many lines there are between it and FINAL RESULTS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With