-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathscript-11.sh
More file actions
executable file
·12 lines (8 loc) · 718 Bytes
/
script-11.sh
File metadata and controls
executable file
·12 lines (8 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
set -euo pipefail
# The input for this script is the scores.json file.
# TODO: Write a command to output the total of adding together all scores from all games from all players.
# Your output should be exactly the number 164.
# [{"name": "Ahmed", "city": "London", "scores": [1, 10, 4]}, {"name": "Basia", "city": "London", "scores": [22, 9, 6]}, {"name": "Mehmet", "city": "Birmingham", "scores": [3, 12, 17]}, {"name": "Leila", "city": "London", "scores": [1]}, {"name": "Piotr", "city": "Glasgow", "scores": [15, 2, 25, 11, 8]}, {"name": "Chandra", "city": "Birmingham", "scores": [12, 6]}]
# jq -r '.[] | .scores[0] | add' scores.json nned nums in array
jq -r '[.[] | .scores[]] | add' scores.json