Oct 18, 2007 #1 tini1208 Technical User Feb 13, 2006 56 DE hi everybody, is there a short command, to caculate the mean of a column? thanks, tini
Oct 18, 2007 1 #2 feherke Programmer Aug 5, 2002 9,540 RO Hi If you mean arithmetic mean, then is quite simple : Code: awk 'NF{s+=$1;c++}END{print s/c}' /input/file For example if you want the average file size in a directory : Code: ls -l | awk 'NF>=5{s+=$5;c++}END{print s/c}' Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi If you mean arithmetic mean, then is quite simple : Code: awk 'NF{s+=$1;c++}END{print s/c}' /input/file For example if you want the average file size in a directory : Code: ls -l | awk 'NF>=5{s+=$5;c++}END{print s/c}' Feherke. http://rootshell.be/~feherke/
Oct 18, 2007 Thread starter #3 tini1208 Technical User Feb 13, 2006 56 DE hi feherke, thanks a lot for your quick answer!!!!!! cheers, tini Upvote 0 Downvote