Skip to content

Commit fc0bcc3

Browse files
committed
sum all scores per player
1 parent 1e623c9 commit fc0bcc3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

individual-shell-tools/awk/script-07-stretch.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ set -euo pipefail
55
# NOTE: This is a stretch exercise - it is optional.
66

77
# TODO: Write a command to output just the names of each player along with the total of adding all of that player's scores.
8+
awk '{
9+
sum = 0
10+
for (i = 3; i <= NF; i++) {
11+
sum += $i
12+
}
13+
print $1, sum
14+
}' scores-table.txt
815
# Your output should contain 6 lines, each with one word and one number on it.
916
# The first line should be "Ahmed 15". The second line should be "Basia 37"

0 commit comments

Comments
 (0)