grep/awk column or variable?

Hi, I'm running via PuTTY, in a BASH shell to do my work. I'm running calculations where steps are reported like this every 100 steps:

NSTEP =  249900   TIME(PS) = 249.900  TEMP(K) =   299.94  PRESS = 21.1
 Etot   =    -12912.5557  EKtot   =      4996.8780  EPtot      =    -17909.4336
 BOND   =      3502.4858  ANGLE   =        39.5581  DIHED      =        13.5982
 1-4 NB =         2.4191  1-4 EEL =        71.3522  VDWAALS    =      3805.6043
 EELEC  =    -25344.4513  EHBOND  =   0.0000  RESTRAINT  =         0.0000
 EKCMT  =      1624.0988  VIRIAL  =    1599.4088  VOLUME    = 54265.8517
                                                    Density    =         1.0280
 Ewald error estimate:   0.2435E-03
 ------------------------------------------------------------------------------


 NSTEP = 250000  TIME(PS) = 250.000  TEMP(K) = 300.29  PRESS =   193.8
 Etot   =    -12881.4528  EKtot   =      5002.6739  EPtot      =    -17884.1267
 BOND   =      3487.9960  ANGLE   =        41.0739  DIHED      =        11.4793
 1-4 NB =         1.8325  1-4 EEL =        68.9061  VDWAALS    =      3810.8825
 EELEC  =    -25306.2971  EHBOND  =   0.0000  RESTRAINT  =         0.0000
 EKCMT  =  1674.6162  VIRIAL  =  1447.5445  VOLUME     =     54268.4640
                                                    Density    =         1.0280
 Ewald error estimate:   0.2073E-03
 ------------------------------------------------------------------------------

I need to create data files showing the Etot (for example) over all 2500 entries. I've tried grep "Etot" filename > newfile but then I get something like this:

 Etot   =     -8020.5755  EKtot   =         0.0000  EPtot      =     -8020.5755
 Etot   =     -7327.1765  EKtot   =       359.4934  EPtot      =     -7686.6698
 Etot   =     -6736.4171  EKtot   =       625.2909  EPtot      =     -7361.7080
 Etot   =     -6290.5101  EKtot   =       865.9846  EPtot      =     -7156.4947
 Etot   =     -5896.3326  EKtot   =      1039.1907  EPtot      =     -6935.5234
 Etot   =     -5563.3851  EKtot   =      1213.5608  EPtot      =     -6776.9459
 Etot   =     -5307.6959  EKtot   =      1316.2096  EPtot      =     -6623.9055
 

So far, I've just been marking and killing the columns I don't need (ctrl+space at top, ctrl+x at bottom opposite corner of column,r,k), but it's slow when you have 2500 lines. I'm coming up on data that will have 10000 lines and I need to do this quicker. I desire something like this ( which would just be the data for only the Etot column, minus the Etot = portion):

-8020.5755
-7327.1765  
-6736.4171  
-6290.5101  
-5896.3326  
-5563.3851  
-5307.6959

The only reason I mention variables here is that it might be saving it as a variable when it reports it to the output file. I'm not sure though, since I'm still a newbie at Unix

nawk '/Etot/ {print $3}' myFile

Alright thanks. Also, I apologize for not using code boxes.

The line that produced the results I wanted was:

awk '/Etot/ {print $3}' myFile > newfile.dat

---------- Post updated at 12:59 PM ---------- Previous update was at 09:40 AM ----------

Okay so while that command worked for Etot, I still don't understand how the command does what it does. I cannot make it work for VOLUME, EPtot, PRESS, or TEMP.

Hi,

Try this 'perl' script:

$ cat script.pl
use strict;
use warnings;

die "Usage: $0 <word> <file>\n" if  @ARGV < 2; 

my $column = $ARGV[0]; 
open my $file, "<", $ARGV[1] or die "Cannot open file: $!\n";

while (<$file>) { 
    print "$1\n" if /\b${column}\s*=\s*(.*?)\s+/i;
}
$ perl script.pl 
Usage: script.pl <word> <file>
$ perl script.pl etot infile 
-12912.5557
-12881.4528

Regards,
Birei

bash-2.05$ nawk 'match($0,str2find " *= *") {str=substr($0,RSTART+RLENGTH);print substr($0,RSTART+RLENGTH,index(str," ")-1)}' str2find=Etot myFile
-12912.5557
-12881.4528
bash-2.05$
bash-2.05$ nawk 'match($0,str2find " *= *") {str=substr($0,RSTART+RLENGTH);print substr($0,RSTART+RLENGTH,index(str," ")-1)}' str2find=EKtot myFile
4996.8780
5002.6739

Okay so thank you for all the suggestions, but I figured out how to make the awk command work precisely as needed. I've always subscribed to the thought that simpler is better.

Here's what I got:

awk '/VOLUME/ {print $9}' file-to-look-in.file > datafile.dat

For any other newbies, what this does is says:
1) look for lines containing the word "VOLUME"
2) print to screen the 9th variable (text field). For some reason in my results, $1 would correspond to EKCMT, $2 is the = sign, $3 is 1674.6162, etc. to $9 which is the value of VOLUME that I'm wanting.
3) look for all of this data in file-to-look-in.file, then pipe (send to new file) it to a new file datafile.dat

If you wrote something like

awk < 'argument-here' FileToLookIn.file

it would print results straight to your screen, not saving it to a file.

With this command you do not need to know the field number on a line:

awk '/Etot/&&getline{print $1}' RS== infile