diff --git a/cs205_final_exam.sh b/cs205_final_exam.sh old mode 100644 new mode 100755 index 0befa75a..0828a370 --- a/cs205_final_exam.sh +++ b/cs205_final_exam.sh @@ -9,3 +9,29 @@ # 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 pokemon.dat. However, you can assume that any file passed to this script will be formatted exactly the way pokemon.dat is formatted. + +# check for file passed as a parameter +if [ $# -ne 1 ]; then + echo "File: $0 " + exit 1 +fi + +# assign input file +input_file=$1 + +# calculate number of pokemon +total_pokemon=$(wc -l < "$input_file") + +# calculate avg HP +avg_hp=$(awk '{total += $7} END {print total/NR}' "$input_file") + +# calculate avg attack speed +avg_attack=$(awk '{total += $8} END {print total/NR}' "$input_file") + +# print summary of data +echo "======= SUMMARY OF $input_file =======" +echo " Total Pokemon: $total_pokemon" +echo " Avg. HP: $avg_hp" +echo " Avg. Attack: $avg_attack" +echo "======= END SUMMARY =======" + diff --git a/screenshots/Screenshot from 2023-11-03 16-17-15.png b/screenshots/Screenshot from 2023-11-03 16-17-15.png new file mode 100644 index 00000000..4967d5d4 Binary files /dev/null and b/screenshots/Screenshot from 2023-11-03 16-17-15.png differ