Search This Blog

Wednesday, April 12, 2006

Regular expression [βzzz from Dalton]

Very often you need only one number from whole output. Going through all the file is boring, especially if you have more then one file. In these situation regular expression are a great help. For example: I needed to find out the value of βzzz. I figured out from an output file that I needed lines with 3 ZDIPLEN words. I prepared the command which should work:
grep "Z.*Z.*Z" *.out
But I got more than I wanted:
betaccs_rhb-631+gd.out:  PUT TRIPLE: ZDIPLEN  ZDIPLEN  ZDIPLEN ON THE LIST. 
betaccs_rhb-631+gd.out: ZDIPLEN  (unrel.) 0.0000  ZDIPLEN (unrel.) 0.0000  ZDIPLEN (unrel.) 0.0000  -383.12517
So I modified my expression (brackets are only in wanted lines):
Z.*(.*Z.*Z" *.out
BTW. If you want to obtaine the correct value of β you'll have to multiply value from output file by -1.
Post a Comment