![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Appending in a file | vinay123 | Shell Programming and Scripting | 1 | 06-19-2008 03:05 AM |
| Reading specific contents from a file and appending it to another file | dnicky | Shell Programming and Scripting | 5 | 10-04-2005 05:45 AM |
| printing to the screen | UNIX for Advanced & Expert Users | 2 | 10-23-2003 11:19 PM | |
| appending a file | chumba | UNIX for Dummies Questions & Answers | 1 | 05-24-2001 11:09 AM |
| Appending out to a file | Astudent | UNIX for Dummies Questions & Answers | 1 | 10-20-2000 02:17 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Appending to a file without printing to screen
Code:
#!/bin/csh
awk 'BEGIN { print "Name Exam1 Exam2 Exam 3 Total Grade" }' grades | tee gradesorted
awk '{if ($2+$3+$4<50){grade="F"}else if ($2+$3+$4>49 && $2+$3+$4<65)
{grade="D"}else if ($2+$3+$4>64 && $2+$3+$4<80){grade="C"}
else if ($2+$3+$4>79 && $2+$3+$4<90){grade="B"}else{grade="A"}}
{print $0, " ", $2+$3+$4, " ", grade;}' grades | tee gradesorted
|
|
|||||
Quote:
Quote:
|
|
||||
|
I don't know why I was using two awk's...
Thanks for helping clean up my sloppy code. The only problem I'm having, at this point, is sorting the gradessorted file without the header (Name, Exam1, etc.) being on the bottom. Is there a way to exclude lines from a sort? |
|
||||
|
Marvellous. Thanks a bunch!
|
| Sponsored Links | ||
|
|