Skip to content
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
26 changes: 20 additions & 6 deletions cs205_final_exam.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Binary file added screenshots/snip of cmd final.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.