avatar
c*t
2
1. use "cut" command to get the 3rd column.
2. echo it, so that all white spaces become just one space
3. replace space with " + " using "sed" command to obtain format
in # + # + #
4. evaluate the expression using "expr"

【在 g**c 的大作中提到】
: 我有个文件, 有四列, 我想球第三列所有数的平均值可以吗?
avatar
t*a
3
awk '{t+=$3}END{print t/NR}' filename

【在 c*****t 的大作中提到】
: 1. use "cut" command to get the 3rd column.
: 2. echo it, so that all white spaces become just one space
: 3. replace space with " + " using "sed" command to obtain format
: in # + # + #
: 4. evaluate the expression using "expr"

avatar
c*t
4
hoho, I wish I knew awk. Too much to learn :(

【在 t*******a 的大作中提到】
: awk '{t+=$3}END{print t/NR}' filename
avatar
f*h
5
if you know C and reg expression, you almost know awk:-)

【在 c*****t 的大作中提到】
: hoho, I wish I knew awk. Too much to learn :(
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。