uni-assignments

My university programming assignments
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README

cmds (813B)


      1 #!/bin/sh
      2 
      3 # TODO: make error checks: grades: 0 - 100
      4 
      5 echo "First names starting with K or N:"
      6 awk '$1 ~ /^K|N/ {print $2, $1}' grades
      7 echo ""
      8 
      9 echo "Last names starting with C or L:"
     10 awk '$2 ~ /^C|L/ {print $1, $2}' grades
     11 echo ""
     12 
     13 echo "Students with their second grade being > 85:"
     14 awk '{if ($5 > 85 && $5 > 85) print}' grades
     15 echo ""
     16 
     17 echo "Students in the humanities:"
     18 awk '{if ($3 == "Theo") print}' grades
     19 echo ""
     20 
     21 echo "Average grades:"
     22 awk '{
     23 sum = cnt = 0;
     24 for (i = 4; i <= NF; i++) {
     25         sum += $i;
     26         cnt++;
     27 }
     28 print $1, $2, sum / cnt}' grades
     29 echo ""
     30 
     31 echo "Students with their third grade being < 70:"
     32 awk 'BEGIN {cnt = 0} {if ($6 < 70) cnt++;} END {print cnt}' grades
     33 echo ""
     34 
     35 echo "How many student names end in 'is'?"
     36 awk 'BEGIN {cnt = 0} {if ($2 ~ /is$/) cnt++} END {print cnt}' grades