Search Results

Search: Posts Made By: momin
9,544
Posted By neutronscott
added or multiplied? you mean you can have any...
added or multiplied? you mean you can have any number of columns rather than just two?


awk '{p=$1;for(i=2;i<=NF;i++)p*=$i;printf("%.3f\n",p)}'


example:

$ echo 3 .5 2 | awk...
9,544
Posted By rdcwayx
so, you already try in awk, why not write all by...
so, you already try in awk, why not write all by awk?

awk '{printf "%.3f\n", $1*$2}' infile
Showing results 1 to 2 of 2

 
All times are GMT -4. The time now is 02:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy