Last active
October 17, 2017 03:53
-
-
Save notsobad/94cb05408c8c092e5b2d89d26606d3a5 to your computer and use it in GitHub Desktop.
awk计算数据分布区间
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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