Getting started with Shell programming score statistics

Source: Internet
Author: User

Note: If you are the factory of children's shoes, write homework to find this article, I hope you do not copy ^_^, in fact, try to knock on your own will help you a lot.

The title requirement is to student.txt the results of each stage of the statistics, the text format is "study number: Results".

Here is my approach:

#!  bin/bashs=$ (Cat Score.txt | cut-d:-F 2 | tr "", "); arr= ($s); num= (0,0,0,0,0); grade= (0,0,0,0,0); for x in ${arr[@]};d OIF [$ ((x))-lt 100-a $ ((x))-gt];thennum[0]=$ (($ (((num[0)) + 1)); grade[0]=$ ((Grade[0] + $ ((x)))); Elif [$ ((x))-GT 80 ];thennum[1]=$ (($ ((num[1)) + 1)); grade[1]=$ ((Grade[1] + $ ((x))); Elif [$ ((x))-gt (($ ((];thennum[2]=$]) + 1)); grade[2]=$ ((Grade[2] + $ ((x))); Elif [$ ((x))-gt];thennum[3]=$ (($ (((num[3)) + 1)); grade[3]=$ ((Grade[3] + $ ((x))); El Senum[4]=$ (($ ((num[4)) + 1)); grade[4]=$ ((Grade[4] + $ ((x))); Fidoneecho the AVG score of 90~100 is $ ((${grade[0]}/${num [0]}), and the number of student is ${num[0]};echo the Avg. score of 80~89 is $ ((${grade[1]}/${num[1]}), and the number O F student is ${num[1]};echo the AVG score of 70~79 are $ ((${grade[2]}/${num[2]}), and the number of student is ${num[2]}; echo the AVG score of 60~69 is $ ((${grade[3]}/${num[3]}), and the number of student is ${num[3]};echo the AVG score of ~ is $ ((${grade[4)}/${NUM[4])), and the number of student is ${num[4]};  

 

Getting started with Shell programming score statistics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.