Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Help needed with multiplying two values of two columns in a file

$
0
0
Hi, I am trying to multiply column#1 with column#2 using a shell script. How can I make a for-loop script using 1st column as "i" and the second column as "j" from the following file? Please feel free to share any alternative ways to multiplying column#1 with column#2.

HTML Code:

.06    5.0000
.49    7.8750
.18    5.0000
.17    1.0000
.64    6.1250
.01    0.1250
.48    4.81250
.01    0.2500
.77    19.5000

Thanks in advance
:wall:

---------- Post updated at 08:20 PM ---------- Previous update was at 08:16 PM ----------

This is what I tried..... but did not work :(

HTML Code:

root@vna1(/)# for x in `awk '{print $1}' /tmp/temp6`
> do
> for j in `awk '{print $2}' /tmp/temp6`
> do
> echo "scale=3; $x * $y" | bc
> done
> done
syntax error on line 1 stdin
syntax error on line 1 stdin
syntax error on line 1 stdin
syntax error on line 1 stdin
syntax error on line 1 stdin
syntax error on line 1 stdin
syntax error on line 1 stdin


Viewing all articles
Browse latest Browse all 16232

Trending Articles