• We did not send an email asking for donations - please read this post.

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
7,798
Reaction score
6,623
Credits
28,751
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
 

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
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top