Skip to content

Instantly share code, notes, and snippets.

@notsobad
Last active October 17, 2017 03:53
Show Gist options
  • Save notsobad/94cb05408c8c092e5b2d89d26606d3a5 to your computer and use it in GitHub Desktop.
Save notsobad/94cb05408c8c092e5b2d89d26606d3a5 to your computer and use it in GitHub Desktop.
awk计算数据分布区间
awk 'BEGIN{
split("<10 10-100 100-500 500-100 >1000",b)
}{
if($2<10)a[1]++;
else if($2<100)a[2]++;
else if($2<500)a[3]++;
else if($2<1000)a[4]++;
else a[5]++
}END{
for(i in a)print b[i] "\t" a[i]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment