read the file, add number and get the average
Hi
I have a file which has several entries with
# comment 1
1245
# comment 2
5667
# comment 3
456456
how can I read the file, sum the numbers ( "avoid" the #lines) and then get the average of the numbers?
I do
awk '{s+=$0} END {print s}' /tmp/file.txt
and this give me the sum correctly, but how can I get also the average ?
Thanks in advance!
Last edited by Alkass; 04-29-2010 at 05:57 PM.
|