文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>awk高级编程

awk高级编程

时间:2008-09-23  来源:isqlw

[root@server0 b]# cat grade
35#senior
45#junior
65#junior
69#senior
69#junior
45#senior
72#junior
78#senior
80#junior
85#junior
90#senior
91#junior
96#junior
[root@server0 b]# ./awk_array.sh grade
the score 0-60 has 3 students
the score 70-80 has 2 students
the score 90-100 has 3 students
the score 60-70 has 3 students
the score 80-90 has 2 students
the class has 5 senior students
the class has 8 junior students
[root@server0 b]#
[root@server0 b]# cat awk_array.sh
#!/bin/awk -f
#awk_array.sh
BEGIN{
 FS="#" #-F "#"
 score["0-60"]=0
 score["60-70"]=0
 score["70-80"]=0
 score["80-90"]=0
 score["90-100"]=0
 student["junior"]=0
 student["senior"]=0
}
{
 {if($1<60)
  score["0-60"]++
 }
 {if($1<70&&$1>=60)
  score["60-70"]++
 }
 {if($1<80&&$1>=70)
  score["70-80"]++
 }
 {if($1<90&&$1>=80)
  score["80-90"]++
 }
 {if($1<=100&&$1>=90)
  score["90-100"]++
 }
}

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载