From 7945df3000579aec1aa2b360ba97144833bef839 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 18:53:38 +0000 Subject: [PATCH 01/11] print the value for the key name as a raw string --- jq/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-01.sh b/jq/script-01.sh index 95827f68..0d69705d 100755 --- a/jq/script-01.sh +++ b/jq/script-01.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the name of the person. # Your output should be exactly the string "Selma", but should not contain any quote characters. +jq -r '.name' person.json From a063e88d5ed86538ea421d244c1d6818747a169a Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 19:15:10 +0000 Subject: [PATCH 02/11] access address key and output value all in one line - no quotes. --- jq/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-02.sh b/jq/script-02.sh index 21544d67..53e96a7e 100755 --- a/jq/script-02.sh +++ b/jq/script-02.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the address of the person, all on one line, with a comma between each line. # Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters. +jq '.address' person.json | jq -r 'join(", ")' \ No newline at end of file From 842605a3d58547deafd444872316ce4780f95399 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 19:19:29 +0000 Subject: [PATCH 03/11] output the values for the name and profession keys, respectively,. All in one line and a comma in between --- jq/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-03.sh b/jq/script-03.sh index 3566f03b..53c48e95 100755 --- a/jq/script-03.sh +++ b/jq/script-03.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the person.json file. # TODO: Write a command to output the name of the person, then a comma, then their profession. # Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters. +jq -j '.name, ", " ,.profession' person.json \ No newline at end of file From b973fe49738c9d75c0f63f3d6d3f46b03fe9d273 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 19:21:49 +0000 Subject: [PATCH 04/11] output the names all in one lines, no quotes --- jq/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-04.sh b/jq/script-04.sh index 015997e1..7fb3777d 100755 --- a/jq/script-04.sh +++ b/jq/script-04.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player, one per line. # Your output should contain 6 lines, each with just one word on it. # Your output should not contain any quote characters. +jq -r '.[].name' scores.json \ No newline at end of file From 5b68c15e74708e05b7815d3f836a57e1f607bcd8 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 19:39:30 +0000 Subject: [PATCH 05/11] output each player and their respective city (one line per player) --- jq/script-05.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-05.sh b/jq/script-05.sh index 993fc9ee..9d9fca5d 100755 --- a/jq/script-05.sh +++ b/jq/script-05.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the scores.json file. # TODO: Write a command to output the names of each player, as well as their city. # Your output should contain 6 lines, each with two words on it. +jq -r '.[] | "\(.name), \(.city)"' scores.json \ No newline at end of file From e14f00032c25d952c31a9d48121ea83e3f6c67b7 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 19:43:01 +0000 Subject: [PATCH 06/11] display in every single line the name of each player along with their first socre attempts --- jq/script-05.sh | 2 +- jq/script-06.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jq/script-05.sh b/jq/script-05.sh index 9d9fca5d..02f0a2bc 100755 --- a/jq/script-05.sh +++ b/jq/script-05.sh @@ -5,4 +5,4 @@ set -euo pipefail # The input for this script is the scores.json file. # TODO: Write a command to output the names of each player, as well as their city. # Your output should contain 6 lines, each with two words on it. -jq -r '.[] | "\(.name), \(.city)"' scores.json \ No newline at end of file +jq -r '.[] | "\(.name) \(.city)"' scores.json \ No newline at end of file diff --git a/jq/script-06.sh b/jq/script-06.sh index 8b6e74c5..4b895639 100755 --- a/jq/script-06.sh +++ b/jq/script-06.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their first attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 1" with no quotes. +jq -r '.[] | "\(.name) \(.scores[0])"' scores.json \ No newline at end of file From c5235651d7f948a264a463ffb04d654d7119164d Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 20:12:39 +0000 Subject: [PATCH 07/11] in one line: display each player and its respective last score --- jq/script-07.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-07.sh b/jq/script-07.sh index d43f93d1..75c87d20 100755 --- a/jq/script-07.sh +++ b/jq/script-07.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the score from their last attempt. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 4" with no quotes. +jq -r '.[] | "\(.name) \(.scores[- 1])"' scores.json \ No newline at end of file From bf6fc287e814c86abffb407c1c4d1942835d73c3 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 20:20:14 +0000 Subject: [PATCH 08/11] on each line show each player and the number of the attempts --- jq/script-08.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-08.sh b/jq/script-08.sh index 6671fd1b..ecd84638 100755 --- a/jq/script-08.sh +++ b/jq/script-08.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the number of times they've played the game. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 3" with no quotes. +jq -r '.[] | "\(.name) \(.scores | length)"' scores.json \ No newline at end of file From bb5cb456443b8fe58eb3ca407389b2e99e3d81f2 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 20:24:38 +0000 Subject: [PATCH 09/11] in one line each player and the sum of the scores --- jq/script-09.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-09.sh b/jq/script-09.sh index c2536a53..169ea0d6 100755 --- a/jq/script-09.sh +++ b/jq/script-09.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the total scores from all of their games added together. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 15" with no quotes. +jq -r '.[] | "\(.name) \(.scores | add)"' scores.json \ No newline at end of file From 8e0aea71881dab6117b748d56e9fc295edc6c099 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 20:38:25 +0000 Subject: [PATCH 10/11] output the total of all first scores across all players --- jq/script-10.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-10.sh b/jq/script-10.sh index 8e9d75f0..f6a01704 100755 --- a/jq/script-10.sh +++ b/jq/script-10.sh @@ -5,3 +5,4 @@ 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 players' first scores. # Your output should be exactly the number 54. +jq '[.[].scores[0]] | add' scores.json \ No newline at end of file From 621c391d0ef0108c863e4926ab65c40f586f3e6f Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 14 Nov 2025 20:46:55 +0000 Subject: [PATCH 11/11] diplay the total scores of all attempts of all players --- jq/script-11.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jq/script-11.sh b/jq/script-11.sh index d2337a6b..a55d91c1 100755 --- a/jq/script-11.sh +++ b/jq/script-11.sh @@ -5,3 +5,4 @@ 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. +jq '[.[].scores[]] | add' scores.json \ No newline at end of file