Article 52P9N make a sum in the awk command

make a sum in the awk command

by
Drosera_capensis
from LinuxQuestions.org on (#52P9N)
Hello everyone,

I would like to make the ratio of all the 50 numbers that are in a column of a file. So, the ratio version of a column of numbers.
The ratio would be equal to row value / sum of all the column.

Code:for f in {1..50};
do
cat file | awk ' {sum += $1} {a = $1; b = sum; print (a/b)}' ;
doneBut the sum given by the first part of the awk command is the sum of the row already processed, and not the sum of the 50 rows of the document.

Would anyone know how to make the sum of all the rows of the documents at any loop?

Thanks for the help!latest?d=yIl2AUoC8zA latest?i=KN_vQP1yh5g:gaIgQp4sDaU:F7zBnMy latest?i=KN_vQP1yh5g:gaIgQp4sDaU:V_sGLiP latest?d=qj6IDK7rITs latest?i=KN_vQP1yh5g:gaIgQp4sDaU:gIN9vFwKN_vQP1yh5g
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments