Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Hundreds of files need manual preparation. Does shell script could do it automatically?

$
0
0
Hello friends,

I have hundreds files in hand, which need extract some data from logs and read these data into an input file.
Here I will explain in detail using these two files as attached. read some data from .log file and write it into the .in file.
**explanation is given inside two stars**

Here shows the final .in file:
Code:

Title of the job
feco4_s **it needs to be replaced by the name of log file**
Important Comment: The number of lines in the input file, and the
  *exact* typography for text input needs to be *rigorously* followed !!!!!!!!!
Temperatures (Next two lines: "List", or "Interval", then no of temps.)
  List
  1
Values (If "Interval", give start and finish temp.)
  298.15
Pressure (in atm or bar - if given in atm, enter as a negative number. -1 is the G09 default)
 -1.
Calculated properties of the species (e.g. from Gaussian output)
Electronic Energy
 -1715.8231094  **grep "SCF Done:" will get this number, but always use the number from the last line. there could be a lot of these matches **
Nature of species (Atom = 0, Linear = 1, or General = 3)
  3
Rotational factor (symmetry factor)
  2. **grep "Rotational symmetry number"; all the matches will give the same number, use the number here and put a dot at the end**
Electronic degeneracy (multiplicity)
  1. **grep "Multiplicity"; all the matches will give the same number, use the number here and put a dot at the end**
Molecular Weight (amu)
167.91460 ** grep "Molecular mass" **
Moments of Inertia (in amu x au2; none for Atom, 1 for Linear, 3 for General)
1284.73849
1536.05333
2170.19761
**grep "    Eigenvalues -- "; here is very tricky; three numbers are given without any space,
which means we need extract three numbers from a string of numbers and dots. the number are always with five digits follows the each dot,
no matter how many digits in the integer parts**

Vibrational Frequencies (first line: number; then freqs. in cm-1)
  21 ** grep " Frequencies -- "; will show a list of numbers;
remove the first column of text and put all the numbers from three columns into a single column.
it doesn't matter what the sequence is. the number in the first line is the 'total number' of the numbers below**

  45.7886
  96.4952
 353.2741
 427.8395
 499.7992
 640.4272
2062.0748
  66.7894
  96.9991
 363.5129
 430.9072
 537.9941
 640.7995
2062.6585
  79.7836
 335.4020
 422.7705
 448.4787
 595.3209
2042.2981
2151.4066

I understand this is non trivial work to do it with bash. probably it's better to do it using python or some other advanced programming languages. However, I don't know any of them. I have done some preparations to search these data from log and manually put these data into the .in file. However, there are still hundreds of them waiting to be prepared.
If you could give me some help on this point, it would be save me from desperation. I thank you very much for your kind help in advance! All your help will be much appreciated! Thanks.
Zhen

Attached Files
File Type: txt feco4_s.log.txt (82.3 KB)
File Type: txt feco4_s.in.txt (1.1 KB)

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images