Multiplying the decimals in the column

PonDioS

New Member
Joined
Sep 24, 2022
Messages
2
Reaction score
0
Credits
18
Hi, I want to multiply only the second column by 27.211396132 . I use

awk '{$2=$2*27.211396132 ; print }' input file > output file

The result is wrong . I want the answer to be like 5 -76308.842049 ( for the first line). Please help me.


input file.png
output file.png

input file output file
 


wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,937
Reaction score
7,909
Credits
37,595
Welcome to linux.org

Moving this to Command Line.

Is this homework?

Chris Turner
wizardfromoz
 
OP
P

PonDioS

New Member
Joined
Sep 24, 2022
Messages
2
Reaction score
0
Credits
18
no it's not, I’m converting eV units from hartree but I need to save time I can't calculate each one by one
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,937
Reaction score
7,909
Credits
37,595
OK, thanks - someone will be along when they can. Good luck.

Wizard
 

Lexyan

New Member
Joined
Sep 25, 2022
Messages
1
Reaction score
0
Credits
7
Your decimal separator seems inconsistent between input and output

Try changing LC_NUMERIC to reflect input locale
LC_NUMERIC=en_US.UTF-8 awk --use-lc-numeric '{$2=$2*27.211396132 ; print }' input file > output file
 

Members online


Top