Skip to content

Commit d6ab7ba

Browse files
committed
jq
1 parent 4350f48 commit d6ab7ba

File tree

11 files changed

+11
-0
lines changed

11 files changed

+11
-0
lines changed

jq/script-01.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the name of the person.
7+
jq -r '.name' ./person.json
78
# Your output should be exactly the string "Selma", but should not contain any quote characters.

jq/script-02.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the address of the person, all on one line, with a comma between each line.
7+
jq -r '.address | join(" ")' ./person.json
78
# Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters.

jq/script-03.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the name of the person, then a comma, then their profession.
7+
jq -r '.name +", " + .profession' ./person.json
78
# Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters.

jq/script-04.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output just the names of each player, one per line.
7+
jq -r '.[].name' ./scores.json
78
# Your output should contain 6 lines, each with just one word on it.
89
# Your output should not contain any quote characters.

jq/script-05.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

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.
7+
jq -r '.[] | .name + " " + .city' ./scores.json
78
# Your output should contain 6 lines, each with two words on it.

jq/script-06.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output just the names of each player along with the score from their first attempt.
7+
jq -r '.[] | .name + " " + (.scores[0] | tostring)' ./scores.json
78
# Your output should contain 6 lines, each with one word and one number on it.
89
# The first line should be "Ahmed 1" with no quotes.

jq/script-07.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output just the names of each player along with the score from their last attempt.
7+
jq -r '.[] | .name + " " + (.scores[-1] | tostring)' ./scores.json
78
# Your output should contain 6 lines, each with one word and one number on it.
89
# The first line should be "Ahmed 4" with no quotes.

jq/script-08.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
7+
jq -r '.[] | .name + " " + (.scores | length | tostring)' ./scores.json
78
# Your output should contain 6 lines, each with one word and one number on it.
89
# The first line should be "Ahmed 3" with no quotes.

jq/script-09.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output just the names of each player along with the total scores from all of their games added together.
7+
jq -r '.[] | .name + " " + (.scores | add | tostring)' ./scores.json
78
# Your output should contain 6 lines, each with one word and one number on it.
89
# The first line should be "Ahmed 15" with no quotes.

jq/script-10.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output the total of adding together all players' first scores.
7+
jq -r '[.[] .scores[0]] | add' scores.json
78
# Your output should be exactly the number 54.

0 commit comments

Comments
 (0)