Unix command: Find minimum from column, and do something -


i have following input files

 scfe: scf energy: udft(b3lyp)     -7255.77607552893 hartrees   iterations:  36  scfe: scf energy: udft(b3lyp)     -7256.47180169446 hartrees   iterations:  13  scfe: scf energy: udft(b3lyp)     -7257.05043442327 hartrees   iterations:  25  scfe: scf energy: udft(b3lyp)     -7257.53756596970 hartrees   iterations:   7  scfe: scf energy: udft(b3lyp)     -7257.94483191615 hartrees   iterations:   7  scfe: scf energy: udft(b3lyp)     -7258.28358389906 hartrees   iterations:   7  scfe: scf energy: udft(b3lyp)     -7258.56278138629 hartrees   iterations:   7 ..... 

from file, hope extract minumum value of 5th column of file, , following calculation

cat input.dat | awk '{print ($5 - minimum of 5th column)*627.509}' > output

but i'm not sure how can find, store, , use minimum value of 5th column. thank in advance :)

you need 2 passes ($5 - minimum of 5th column)*627.509 each row

try this:

awk 'nr==fnr{min=min<$5?min:$5;next}{$5=($5-min)*627.509}1' ofs='\t' file file 

$ cat file scfe: scf energy: udft(b3lyp)     -7255.77607552893 hartrees   iterations:  36 scfe: scf energy: udft(b3lyp)     -7256.47180169446 hartrees   iterations:  13 scfe: scf energy: udft(b3lyp)     -7257.05043442327 hartrees   iterations:  25 scfe: scf energy: udft(b3lyp)     -7257.53756596970 hartrees   iterations:   7 scfe: scf energy: udft(b3lyp)     -7257.94483191615 hartrees   iterations:   7 scfe: scf energy: udft(b3lyp)     -7258.28358389906 hartrees   iterations:   7 scfe: scf energy: udft(b3lyp)     -7258.56278138629 hartrees   iterations:   7 

$ awk 'nr==fnr{min=min<$5?min:$5;next}{$5=($5-min)*627.509}1' ofs='\t' file file scfe:   scf energy: udft(b3lyp) 1748.68 hartrees    iterations: 36 scfe:   scf energy: udft(b3lyp) 1312.11 hartrees    iterations: 13 scfe:   scf energy: udft(b3lyp) 949.011 hartrees    iterations: 25 scfe:   scf energy: udft(b3lyp) 643.332 hartrees    iterations: 7 scfe:   scf energy: udft(b3lyp) 387.769 hartrees    iterations: 7 scfe:   scf energy: udft(b3lyp) 175.199 hartrees    iterations: 7 scfe:   scf energy: udft(b3lyp)       0 hartrees    iterations: 7 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -