Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated pokemon awk scriopt #429

Open
wants to merge 1 commit into
base: Spring2024
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cs205_final_exam.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
if [ $# -ne 1 ]; then
echo "usage: $0 <best_pokemon.dat>"
exit 1
fi
data_files="$1"
total_pokemon=$(awk 'NR>1 { count++; hp_sum+=$3; attack_sum+=$4 } END { printf("%d", count) ] }' "best_pokemon.dat")
avg_hp=$(awk 'NR>1 { count++; hp_sum+=$3; attack_sum+=$4 } END { printf("%.2f", hp_sum/ count) }' "best_pokemon.dat")
avg_attack=$(awk 'NR>1 { count++; hp_sum+=$3; attack_sum+=$4 } END { printf("%.2f", attack_sum/ NR) }' "best_pokemon.dat")
echo "===== SUMMARY OF DATA FILE ====="
echo " File name: best_pokemon.dat"
echo " Total Pokemon: $total_pokemon"
echo " Avg. HP: $avg_hp"
echo " Avg. Attack: $avg_attack"
echo "===== END SUMMARY ====="
# 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]
Expand Down
Binary file added screenshots/Screenshot 2024-05-07 214502.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.