diff --git a/cs205_final_exam.sh b/cs205_final_exam.sh index d0d0d57c..c72790e6 100644 --- a/cs205_final_exam.sh +++ b/cs205_final_exam.sh @@ -1,10 +1,24 @@ # TODO: Modify this file to create a shell script that is able to use awk to go through a file formatted like best_pokemon.dat and provides a printed report in the following format (where your script correctly calculates the values that go into the [VALUE] placeholders): -# ===== SUMMARY OF DATA FILE ===== -# File name: [VALUE] -# Total Pokemon: [VALUE] -# Avg. HP: [VALUE] -# Avg. Attack: [VALUE] -# ===== END SUMMARY ===== +# +BEGIN{ +FS="\t"; +rows=0 +hp=0 +attack=0 +} +{if (NR != 1){ +rows +=1 ; +hp+= $6; +attack+=$7; +}} +END{ +print"===== SUMMARY OF DATA FILE ====="; +print" File name:" FILENAME; +print" Total Pokemon:" rows ; +print" Avg. HP:" hp/rows; +print" Avg. Attack:" attack/rows; +print "===== END SUMMARY ====="; +} # The "Avg." values should be calculated as mean values for the corresponding columns. # The spacing and header formatting should match the above formatting description exactly. diff --git a/screenshots/snip of cmd final.PNG b/screenshots/snip of cmd final.PNG new file mode 100644 index 00000000..30260ceb Binary files /dev/null and b/screenshots/snip of cmd final.PNG differ