gpa...@gmail.com
2020-11-19 07:02:37 UTC
Hi Experts,
I need to multiply a column in a file with float numbers, say with (1.1 + 0.25)
I have a extracted column 3 ( with Numbers) with awk command from file file1.txt
awk '{ print $3 }' file1.txt > coloumn1
1.0
1.2
1.3
I want to multiply all column values with (1.1 + 0.25)to achieve the following values. requirement is to use different p1 values. p1 is 1.1
( 1.0*(p1+0.25))
( 1.2*(p1+0.25))
( 1.3*(p1+0.25))
1.250
1.500
1.625
My script is
#bin/bash
p1=1.0
val=`echo $p1 + 0.25 | bc`
awk -F, '{$1*=$val}1' OFS=, coloumn1 > coloumn_mod
But above awk command is not returning the expected result , it gave like (1.1*$val)
Could you please help correcting the above command ?
I need to multiply a column in a file with float numbers, say with (1.1 + 0.25)
I have a extracted column 3 ( with Numbers) with awk command from file file1.txt
awk '{ print $3 }' file1.txt > coloumn1
1.0
1.2
1.3
I want to multiply all column values with (1.1 + 0.25)to achieve the following values. requirement is to use different p1 values. p1 is 1.1
( 1.0*(p1+0.25))
( 1.2*(p1+0.25))
( 1.3*(p1+0.25))
1.250
1.500
1.625
My script is
#bin/bash
p1=1.0
val=`echo $p1 + 0.25 | bc`
awk -F, '{$1*=$val}1' OFS=, coloumn1 > coloumn_mod
But above awk command is not returning the expected result , it gave like (1.1*$val)
Could you please help correcting the above command ?