Peter.Paul

November 28th, 2010, 09:09 PM

Hello,

I am trying to calculate an average value and write it into a file. The calculation of the average works perfect, but it seems like, I cannot put it on a variable and print it out.

So, this works perfect

awk 'BEGIN{total=0;} {total+=$1} END{printf (total/50)}' $1tail.txt >> temp.txtAnd this one does not:

variable = awk 'BEGIN{total=0;} {total+=$1} END{printf (total/50)}' $1tail.txt >> temp.txt

echo "$variable is the average. The highest value is $high"

Can you help me out with this?

I am trying to calculate an average value and write it into a file. The calculation of the average works perfect, but it seems like, I cannot put it on a variable and print it out.

So, this works perfect

awk 'BEGIN{total=0;} {total+=$1} END{printf (total/50)}' $1tail.txt >> temp.txtAnd this one does not:

variable = awk 'BEGIN{total=0;} {total+=$1} END{printf (total/50)}' $1tail.txt >> temp.txt

echo "$variable is the average. The highest value is $high"

Can you help me out with this?