I have a lot of subfolders in a parent folder and inside each subfolder, there is a log file. Inside the log file I have a lot of data like this:
> Rotational constants (GHZ): 0.0423083 0.0029364
> 0.0027927 Standard basis: 6-31G(d,p) (6D, 7F) There are 1566 symmetry adapted cartesian basis functions of A symmetry. There are
> 1566 symmetry adapted basis functions of A symmetry. 1566 basis
> functions, 3052 primitive gaussians, 1566 cartesian basis functions
> 355 alpha electrons 355 beta electrons
> nuclear repulsion energy 15971.0567247177 Hartrees. NAtoms= 130 NActive= 130 NUniq= 130 SFac= 1.00D+00 NAtFMM= 60
> NAOKFM=T Big=T Integral buffers will be 131072 words long.
> Raffenetti 2 integral format. Two-electron integral symmetry is
> turned on. One-electron integrals computed using PRISM. NBasis=
> 1566 RedAO= T EigKep= 2.31D-04 NBF= 1566 NBsUse= 1566 1.00D-06
> EigRej= -1.00D+00 NBFU= 1566 Initial guess from the checkpoint file:
> > 0.000000 0.000000 0.000000
> Rot= 1.000000 -0.000006 0.000001 -0.000001 Ang= 0.00 deg. Requested convergence on RMS density matrix=1.00D-08 within 128 cycles. Requested convergence on MAX density matrix=1.00D-06.
> Requested convergence on energy=1.00D-06. No special
> actions if energy rises. SCF Done: E(RB3LYP) = -8526.66394979
> A.U. after 6 cycles
> NFock= 6 Conv=0.72D-08 -V/T= 2.0055 Calling FoFJK, ICntrl= 2127 FMM=T ISym2X=0 I1Cent= 0 IOpClX= 0 NMat=1 NMatS=1
> NMatT=0.
As an example, I am looking for SCF Done: E(RB3LYP) = -8526.66394979
in the abovementioned text. the value after the =
changes in each file. What I need is to extract all the values and put them in a text file in the parent folder. For example, I have 3 folders: bar, baz, and foo. Now I need the following result:
bar : -8526.66394979
baz : -112232.123391
foo : 12312313:34574
After running the following script, I will have only one value (i.e -8526.66394979). Could you please help me to fix the problem?
#!/bin/bash
for file_name in *
do
cd $file_name
EE=$(grep -i 'scf done' *.log | tail -1 | awk 'NR==1 {print $5}')
echo "Electronic Energy : $EE" | column -t -s ":" > ${file_name%%.*}.txt
mv ${file_name%%.*}.txt ../
done
scf done
?