#!/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
What I'm trying to do change both the prints so that what's in the quotations gets appended to the file rather than printed to the screen. I've tried using sed with no success. Can anyone point me in the right direction? Thanks.
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?