Skip to content

Commit b5f6bfd

Browse files
committed
Add jq commands to extract player names, cities, and scores from scores.json
- script-05.sh: Output each player's name and city on one line. - script-06.sh: Output each player's name and their first score. - script-07.sh: Output each player's name and their last score.
1 parent 70e7660 commit b5f6bfd

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

jq/script-05.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output the names of each player, as well as their city.
77
# Your output should contain 6 lines, each with two words on it.
8+
9+
jq -r '.[] | "\(.name) \(.city)"' ./scores.json

jq/script-06.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the score from their first attempt.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 1" with no quotes.
9+
10+
jq -r '.[] | "\(.name) \(.scores[0])"' scores.json
11+
12+
13+
14+

jq/script-07.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the score from their last attempt.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 4" with no quotes.
9+
10+
jq -r '.[] | "\(.name) \(.scores[-1])"' scores.json
11+

0 commit comments

Comments
 (0)