I have posted a question here how to extract specific information from many text files
Someone commented that I must break the question to smaller peaces and try then to combine them in order to get my answer
So I have 200 txt files in a folder in my desktop. I want to read them one by one and search for specific information
Now I want to get the information from one txt file in a folder. the example text file is in the other question and that is why I did not post it here to avoid replicate.
Someone proposed that I do it as follows: which I could not figure out how to set it up. I did as follows but it did not really work
Dir.glob('files/*').each { |path| file = File.open(path) }
here is what I personally do
for file in /Users/admin/Desktop/*.txt; do
while read -r line; do
echo "$line"
done < "$file"
done
so it reads all the files that are txt in my folder and print each line
now my question is how to extract specific info from them. I want to extract the following information from each file
HEAT OF FORMATION = -25.54241 KCAL/MOL = -106.86944 KJ/MOL
TOTAL ENERGY = -444.38126 EV
ELECTRONIC ENERGY = -840.31531 EV
CORE-CORE REPULSION = 395.93406 EV
GRADIENT NORM = 0.91931 = 0.45965 PER ATOM
DIPOLE = 2.66600 DEBYE POINT GROUP: C2v
NO. OF FILLED LEVELS = 6
IONIZATION POTENTIAL = 10.352991 EV
HOMO LUMO ENERGIES (EV) = -10.353 0.402
MOLECULAR WEIGHT = 30.0262
COSMO AREA = 60.70 SQUARE ANGSTROMS
COSMO VOLUME = 42.52 CUBIC ANGSTROMS