![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Enterprise Unix Roundup: The Ghost of Unix Future - Server Watch | iBot | UNIX and Linux RSS News | 0 | 12-19-2007 12:20 PM |
| Running UNIX commands remotely in Windows box from Unix box – avoid entering password | D.kalpana | UNIX for Dummies Questions & Answers | 1 | 04-20-2007 05:24 AM |
| FTP script for sending a file from one unix directory to another unix server director | raja_1234 | Shell Programming and Scripting | 1 | 11-30-2006 07:57 AM |
| Unix History Question: Why are filenames/dirnames case sentsitive in Unix? | deckard | UNIX for Dummies Questions & Answers | 3 | 03-26-2005 01:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
AWK Help (New to UNIX)
Write a script to calculate the average score and assign a letter grade for each student, also compute the average score for every test (the source data is in the file “grades”). Output all students’ name, scores, and grades in descending order of the average score. Note: please save the output to the file “finalgrades”.
Contents of source data file (grades): Peter:90:80:70 Alice:79:89:69 David:99:79:89 The final letter grade will be determined based on the following criteria: A: 90 and above; B: 80 thru 89; C: 70 thru 79; D: 60 thru 69; E; 50 thru 59; F: <50. Output (finalgrades) so far i have: Code:
BEGIN{ print "Name Test1 Test2 Test3 Average Grade"}
{average=($2+$3+$4)/3;
grade="F"
if (average<50)
grade="E"
if (average<60)
grade="D"
if (average<70)
grade="C"
if (average<80)
grade="B"
if (average<90)
grade="A"
if (average<100)
printf("%-8s%-8d%-8d%-8d%-8d%-8d\n",$1,$2,$3,$4,average,grade)}
but grade is not working either please help |
|
||||
|
Pipe the output of awk through tail
Code:
... | tail -1 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|