From e89dd2e9c4a8d978dfb2e0e7de37088c599fdbbf Mon Sep 17 00:00:00 2001 From: Draklles <88522100+Draklles@users.noreply.github.com> Date: Wed, 8 May 2024 02:24:55 -0700 Subject: [PATCH 1/4] Update cs205_final_exam.sh --- cs205_final_exam.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/cs205_final_exam.sh b/cs205_final_exam.sh index d0d0d57c..938d3170 100644 --- a/cs205_final_exam.sh +++ b/cs205_final_exam.sh @@ -10,3 +10,42 @@ # The spacing and header formatting should match the above formatting description exactly. # There should be a comment explaining the purpose of each line in your shell script. # The data file will be passed in to the script as a positional parameter and will not necessarily be called best_pokemon.dat. However, you can assume that any file passed to this script will be formatted exactly the way best_pokemon.dat is formatted. + + +#NOTE +#I COULD NOT GET THE SCRIPT TO RUN WITH THE ./ WAY THE PROGRAM PROPOSES +#I SPENT TOO MUCH TIME BEFORE READING EVERYTHING DEEPLY ENOUGH :( + +#program begin + #variable initialization +BEGIN{ sum1 = 0 +sum2 = 0 +} +#counts the total number of pokemon for avgs +NR == 1{next} +{ +#counts up the respective hp and attack of each +#pokemon and adds it to a sum +sum1 += $6 +sum2 += $7 +} +#calculates the average hp and attack using +#the total pokemon number found before +END{ sum1 = sum1/NR; +sum2 = sum2/NR +#intro print +print "===== SUMMARY OF DATA FILE =====" +#filename print +printf " File name: " +print FILENAME +#total pokemon print +printf " total Pokemon: " +print NR +#average hp print +printf " Avg. hp: " +print sum1 +#average attack print +printf " Avg. attack: " +print sum2 +print "===== END SUMMARY =====" +} From 8a8778b164f825f8650869c27b9ecb7256e1a4fd Mon Sep 17 00:00:00 2001 From: Draklles <88522100+Draklles@users.noreply.github.com> Date: Wed, 8 May 2024 02:29:18 -0700 Subject: [PATCH 2/4] Update cs205_final_exam.sh Couldn't figure out how to get it to work with the ./ command method because i didn't read deeply enough before starting the script. From 3c98e6bc9aa92f29008ff5ca250f79e6ac66931c Mon Sep 17 00:00:00 2001 From: Draklles <88522100+Draklles@users.noreply.github.com> Date: Wed, 8 May 2024 02:39:20 -0700 Subject: [PATCH 3/4] Update cs205_final_exam.sh changing one word to a synonym because i forgot to get the pull request link and have to make a new one --- cs205_final_exam.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cs205_final_exam.sh b/cs205_final_exam.sh index 938d3170..0df52e0f 100644 --- a/cs205_final_exam.sh +++ b/cs205_final_exam.sh @@ -13,7 +13,7 @@ #NOTE -#I COULD NOT GET THE SCRIPT TO RUN WITH THE ./ WAY THE PROGRAM PROPOSES +#I COULD NOT GET THE SCRIPT TO RUN WITH THE ./ FORMAT THE PROGRAM PROPOSES #I SPENT TOO MUCH TIME BEFORE READING EVERYTHING DEEPLY ENOUGH :( #program begin From 2e88c8c08115f0c98063b12f9b0e73d3d083e64f Mon Sep 17 00:00:00 2001 From: Draklles <88522100+Draklles@users.noreply.github.com> Date: Wed, 8 May 2024 02:41:04 -0700 Subject: [PATCH 4/4] Update cs205_final_exam.sh --- cs205_final_exam.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cs205_final_exam.sh b/cs205_final_exam.sh index 0df52e0f..059adbdc 100644 --- a/cs205_final_exam.sh +++ b/cs205_final_exam.sh @@ -13,7 +13,7 @@ #NOTE -#I COULD NOT GET THE SCRIPT TO RUN WITH THE ./ FORMAT THE PROGRAM PROPOSES +#I COULD NOT GET THE SCRIPT TO RUN WITH THE ./ FORMATTING THE PROGRAM PROPOSES #I SPENT TOO MUCH TIME BEFORE READING EVERYTHING DEEPLY ENOUGH :( #program begin