在数字列表使用awk来斌值 [英] Using awk to bin values in a list of numbers

查看:111
本文介绍了在数字列表使用awk来斌值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含许多柱的侧向承载力大的数据文件,我想斌的(说)第三列,并输出到一个单独的文件。

I have a large data file consisting of many colums, and i would like to bin the (say) third column and output to a separate file.

通过分档我的意思是以下内容:

By binning i mean the following:

我有号码清单说:

1
4
1
1
1
1

我要套(说)连续三个数字的平均值。

I want the average of sets of (say) three consecutive numbers.

我的最终输出应

2
1

第一项是平均

1
4
1

和第二项是接下来的三个数字的平均值,

And the second entry is the average of the next three numbers,

1
1
1

我如何实现这一目标用awk?

How do i achieve this using awk?

推荐答案

使用此awk命令:

awk '{sum+=$1} NR%3==0 {print sum/3; sum=0}' inFile

这篇关于在数字列表使用awk来斌值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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