从命令行获取一组数字的平均值的最快方法是什么? [英] What's the quickest way to get the mean of a set of numbers from the command line?

查看:171
本文介绍了从命令行获取一组数字的平均值的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用任何你希望在nix系统上找到的工具(事实上,如果你想,msdos也很好),计算一组数字平均值的最简单/最快的方法是,假设你

Using any tools which you would expect to find on a nix system (in fact, if you want, msdos is also fine too), what is the easiest/fastest way to calculate the mean of a set of numbers, assuming you have them one per line in a stream or file?

推荐答案

Awk

awk '{total += $1; count++ } END {print total/count}'

这篇关于从命令行获取一组数字的平均值的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆