From f57ca07e552b37b93a6cf7c61e24642dd7d446cc Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Thu, 19 Mar 2026 18:31:41 +0100 Subject: [PATCH 01/33] add ls command --- individual-shell-tools/ls/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 241b62f5e..081f2c7c2 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,3 +13,4 @@ fi # TODO: Write a command to list the files and folders in this directory. # The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. +ls \ No newline at end of file From c6f9aa7183c645eb90a77a05cbe08e3435ba5199 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Thu, 19 Mar 2026 19:12:30 +0100 Subject: [PATCH 02/33] Add ls -R for recursive file listing --- individual-shell-tools/ls/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10f4..708d81d45 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. +ls -R \ No newline at end of file From 64a6f3fe06439d45fdc9802d9ca05028bf78d46e Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Thu, 19 Mar 2026 19:25:55 +0100 Subject: [PATCH 03/33] List files in child-directory --- individual-shell-tools/ls/script-02.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index 708d81d45..9fa05d88b 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,4 +4,4 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. -ls -R \ No newline at end of file +ls child-directory \ No newline at end of file From 35490820a8f41c588b58d4cdd348f9ed25753c2e Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Thu, 19 Mar 2026 19:28:57 +0100 Subject: [PATCH 04/33] Add ls -R for recursive listing --- individual-shell-tools/ls/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 781216d21..5161171ec 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,3 +5,4 @@ set -euo pipefail # TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders. # The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more). # The formatting of the output doesn't matter. +ls -R From f5141f45ca05cef30245b65f60da9800f5b96a62 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Thu, 19 Mar 2026 19:41:07 +0100 Subject: [PATCH 05/33] Add ls -t and ls -rt commands for time-sorted directory listing --- individual-shell-tools/ls/script-04.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 72f3817b3..62e55be22 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -15,9 +15,10 @@ echo "First exercise (sorted newest to oldest):" # TODO: Write a command which lists the files in the child-directory directory, one per line, sorted so that the most recently modified file is first. # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. - +ls -t "${script_dir}/child-directory" echo "Second exercise (sorted oldest to newest):" # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. +ls -rt "${script_dir}/child-directory" \ No newline at end of file From 7e14727b7ffed5c764608f3402d73bc8ed47967f Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:30:32 +0100 Subject: [PATCH 06/33] Add cat command to output helper-1.txt contents --- individual-shell-tools/cat/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index c85053e0f..866ffd553 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. # The output of this command should be "Once upon a time...". +cat "$(dirname "$0")/../helper-files/helper-1.txt" \ No newline at end of file From 81c6da617aec3063b0af561f998cbdbc088e5ef4 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:32:32 +0100 Subject: [PATCH 07/33] Output all helper files with single cat command --- individual-shell-tools/cat/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 01bbd5eab..33b2e35c8 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,3 +11,4 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... +cat ../helper-files/helper-{1..3}.txt \ No newline at end of file From a914c8d67ee3e513e399b888175fe60769da63e9 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:38:22 +0100 Subject: [PATCH 08/33] Uses cat -n to display numbered lines from the file. --- individual-shell-tools/cat/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index 37573b0c1..e4c6d99f6 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,3 +9,4 @@ set -euo pipefail # 1 It looked delicious. # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... +cat -n ../helper-files/helper-3.txt \ No newline at end of file From 0fcb5a5f67599c23f90c29f77a3c9c24cef3b500 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:40:16 +0100 Subject: [PATCH 09/33] Display all helper files with continuous line numbering --- individual-shell-tools/cat/script-04-stretch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 00fe3c48b..b2949abc2 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,3 +13,4 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... +cat ../helper-files/* | cat -n \ No newline at end of file From d09c8ad7dfff46e4c95f5281d5754296a6e5d311 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:43:41 +0100 Subject: [PATCH 10/33] Outputs word count (19) for the specified file. --- individual-shell-tools/wc/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index c9dd6e5df..2b1e87d63 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the number of words in the file helper-files/helper-3.txt. # The output should include the number 19. The output should not include the number 92. +wc -w ../helper-files/helper-3.txt \ No newline at end of file From 7a44593eeacdecd47cc83683edfb3441f3c1cf02 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:47:35 +0100 Subject: [PATCH 11/33] Count lines in helper-3.txt using wc -l --- individual-shell-tools/wc/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index 8feeb1a62..5520379b9 100755 --- a/individual-shell-tools/wc/script-02.sh +++ b/individual-shell-tools/wc/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the number of lines in the file helper-files/helper-3.txt. # The output should include the number 3. The output should not include the number 19. +wc -l ../helper-files/helper-3.txt \ No newline at end of file From 013bcba0f9a22ede431dea5d102b12734b12414c Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:49:05 +0100 Subject: [PATCH 12/33] Show lines, words, and characters for all helper files --- individual-shell-tools/wc/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index 6b2e9d3d1..e6fdd8699 100755 --- a/individual-shell-tools/wc/script-03.sh +++ b/individual-shell-tools/wc/script-03.sh @@ -8,3 +8,4 @@ set -euo pipefail # 1 7 39 ../helper-files/helper-2.txt # 3 19 92 ../helper-files/helper-3.txt # 5 30 151 total +wc ../helper-files/* \ No newline at end of file From d642ed3ba67ba1cf60548942e7bbafa2fed8e6b4 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 19:58:43 +0100 Subject: [PATCH 13/33] Extract all lines spoken by the Doctor --- individual-shell-tools/grep/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-01.sh b/individual-shell-tools/grep/script-01.sh index fb05f42f2..72cd51b58 100755 --- a/individual-shell-tools/grep/script-01.sh +++ b/individual-shell-tools/grep/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt said by the Doctor. # The output should contain 6 lines. +grep "^Doctor:" dialogue.txt \ No newline at end of file From a2713320faf83bc42b394e1e92ac74c59a70cd78 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:07:10 +0100 Subject: [PATCH 14/33] Find all lines containing doctor case-insensitively --- individual-shell-tools/grep/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index df6f85640..eb861e1fc 100755 --- a/individual-shell-tools/grep/script-02.sh +++ b/individual-shell-tools/grep/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the word Doctor (regardless of case). # The output should contain 9 lines. +grep -i "doctor" dialogue.txt \ No newline at end of file From 2723d0182cc8c1357eb67cc468b98a3c65ffba34 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:09:10 +0100 Subject: [PATCH 15/33] Uses grep -ic to return total count (9) without displaying the actual matching lines. --- individual-shell-tools/grep/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 5383fe578..869dd1c22 100755 --- a/individual-shell-tools/grep/script-03.sh +++ b/individual-shell-tools/grep/script-03.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the number of lines in dialogue.txt that contain the word Doctor (regardless of case). # The output should be exactly the number 9. +grep -ic "Doctor" dialogue.txt \ No newline at end of file From 946ce5c47b578b3462aea7acaf52743901023b0e Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:26:06 +0100 Subject: [PATCH 16/33] Exclude lines containing hello case-insensitively --- individual-shell-tools/grep/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-04.sh b/individual-shell-tools/grep/script-04.sh index 80ee04776..f66a25846 100755 --- a/individual-shell-tools/grep/script-04.sh +++ b/individual-shell-tools/grep/script-04.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that does not contain the word "Hello" (regardless of case). # The output should contain 10 lines. +grep -iv "hello" dialogue.txt \ No newline at end of file From e96c1bf14ba86dbbb1084c18eed320a16a00c8a3 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:35:34 +0100 Subject: [PATCH 17/33] Show lines with cure plus preceding context --- individual-shell-tools/grep/script-05.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index 1eb538185..d9802e0d7 100755 --- a/individual-shell-tools/grep/script-05.sh +++ b/individual-shell-tools/grep/script-05.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output every line in dialogue.txt that contains the string "cure", as well as the line before that line. # The output should contain two pairs of two lines of text (with a separator between them). +grep -B1 "cure" dialogue.txt \ No newline at end of file From f6c0488c71b151b843cf352edb017f977d77def5 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:38:10 +0100 Subject: [PATCH 18/33] List .txt files containing Doctor's dialogue --- individual-shell-tools/grep/script-06.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 5670e3b6c..b20d6564a 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the name of every `.txt` file in this directory which contains a line of dialogue said by the Doctor. # The output should contain two filenames. +grep -l "^Doctor:" *.txt \ No newline at end of file From 8f0f67fa4e0642ab816a5b2b093da419e6574e9a Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:41:56 +0100 Subject: [PATCH 19/33] Uses grep -c to output line counts for each file, showing 6, 2, and 0 lines respectively. --- individual-shell-tools/grep/script-07.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index 9670ebad9..4b287aa4f 100755 --- a/individual-shell-tools/grep/script-07.sh +++ b/individual-shell-tools/grep/script-07.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has. # The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0. +grep -c "^Doctor:" *.txt \ No newline at end of file From c61d719b776643091b88ad3fa6c489aa1e86d5ff Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:47:39 +0100 Subject: [PATCH 20/33] Replace all lowercase 'i' with 'I' in input.txt --- individual-shell-tools/sed/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index d592970fc..6255a124b 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -5,3 +5,4 @@ set -euo pipefail # TODO: Write a command to output input.txt with all occurrences of the letter `i` replaced with `I`. # The output should contain 11 lines. # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". +sed 's/i/I/g' input.txt \ No newline at end of file From 12a0de63753a8c9a89baf88817a64dea7a6e7ea5 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:52:13 +0100 Subject: [PATCH 21/33] Remove all numbers from input.txt --- individual-shell-tools/sed/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-02.sh b/individual-shell-tools/sed/script-02.sh index abdd64d06..d3f70b8ce 100755 --- a/individual-shell-tools/sed/script-02.sh +++ b/individual-shell-tools/sed/script-02.sh @@ -5,3 +5,4 @@ set -euo pipefail # TODO: Write a command to output input.txt with numbers removed. # The output should contain 11 lines. # Line 6 of the output should be " Alisha". +sed 's/[0-9]//g' input.txt \ No newline at end of file From a833eb0480cd2e672f6c1728abec947d31410215 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 20:59:49 +0100 Subject: [PATCH 22/33] Delete lines containing numbers from input.txt --- individual-shell-tools/sed/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-03.sh b/individual-shell-tools/sed/script-03.sh index dd284a296..02b29409e 100755 --- a/individual-shell-tools/sed/script-03.sh +++ b/individual-shell-tools/sed/script-03.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output input.txt removing any line which contains a number. # The output should contain 6 lines. +sed '/[0-9]/d' input.txt \ No newline at end of file From b8378fc38edf14b163b410ec47234259fab41abf Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:05:03 +0100 Subject: [PATCH 23/33] Replace we ll with we will in input.txt --- individual-shell-tools/sed/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 0052ac6c4..478211422 100755 --- a/individual-shell-tools/sed/script-04.sh +++ b/individual-shell-tools/sed/script-04.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output input.txt replacing every occurrence of the string "We'll" with "We will". # The output should contain 11 lines. +sed "s/We'll/We will/g" input.txt \ No newline at end of file From d9c15fd7af0ddbffc62c9f5619c763813959aed5 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:07:37 +0100 Subject: [PATCH 24/33] Swap number and text for lines starting with digits --- individual-shell-tools/sed/script-05.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-05.sh b/individual-shell-tools/sed/script-05.sh index 2dcc91a0c..2b185cce3 100755 --- a/individual-shell-tools/sed/script-05.sh +++ b/individual-shell-tools/sed/script-05.sh @@ -6,3 +6,4 @@ set -euo pipefail # If a line starts with a number and a space, make the line instead end with a space and the number. # So line 6 which currently reads "37 Alisha" should instead read "Alisha 37". # The output should contain 11 lines. +sed 's/^\([0-9]*\) \(.*\)/\2 \1/' input.txt \ No newline at end of file From 61190f0d32beaa0f0a517692bace036ba03abe79 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:15:21 +0100 Subject: [PATCH 25/33] Uses sed to replace comma followed by zero or more spaces with comma-space, fixing oranges,cheese to oranges, cheese while preserving existing spacing. --- individual-shell-tools/sed/script-06.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 0b9390170..3c5f939db 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -8,3 +8,4 @@ set -euo pipefail # The output should contain 11 lines. # Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.". # Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.". +sed 's/, */, /g' input.txt \ No newline at end of file From 379e8ac99c21fa3c51ba7a6917c48974c34fbb4d Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:25:48 +0100 Subject: [PATCH 26/33] Extract player names from scores-table.txt --- individual-shell-tools/awk/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 8db4390af..7e9dc0acc 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in `scores-table.txt`. # Your output should contain 6 lines, each with just one word on it. +awk '{print $1}' scores-table.txt # Correct — prints names \ No newline at end of file From abe54e4ce6dc772142aa5833122bcdc680632aae Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:26:34 +0100 Subject: [PATCH 27/33] Extract player names from scores-table.txt --- individual-shell-tools/awk/script-01.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 7e9dc0acc..1c3a8537d 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -4,4 +4,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in `scores-table.txt`. # Your output should contain 6 lines, each with just one word on it. -awk '{print $1}' scores-table.txt # Correct — prints names \ No newline at end of file +awk '{print $1}' scores-table.txt \ No newline at end of file From 8ddb292a68bb330f088bc90bf84c240a47931a84 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:29:19 +0100 Subject: [PATCH 28/33] Output player names with their cities --- individual-shell-tools/awk/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-02.sh b/individual-shell-tools/awk/script-02.sh index 5956be9bd..5559ca2fb 100755 --- a/individual-shell-tools/awk/script-02.sh +++ b/individual-shell-tools/awk/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # 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, separated by a space. +awk '{print $1, $2}' scores-table.txt \ No newline at end of file From a94b28aeaa48f47994616c23aab842a4a245dc83 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:31:32 +0100 Subject: [PATCH 29/33] Extract player names with first attempt scores --- individual-shell-tools/awk/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index af7c6e8b9..87c511f6e 100755 --- a/individual-shell-tools/awk/script-03.sh +++ b/individual-shell-tools/awk/script-03.sh @@ -5,3 +5,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". +awk '{print $1, $3}' scores-table.txt \ No newline at end of file From 7182d9e6819bb57071967d3e2cbafc52abe20705 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:34:06 +0100 Subject: [PATCH 30/33] Extract London players with their final scores --- individual-shell-tools/awk/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-04.sh b/individual-shell-tools/awk/script-04.sh index bf15703c7..23d8eaf7b 100755 --- a/individual-shell-tools/awk/script-04.sh +++ b/individual-shell-tools/awk/script-04.sh @@ -5,3 +5,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player in London along with the score from their last attempt. # Your output should contain 3 lines, each with one word and one number on it. # The first line should be "Ahmed 4". +awk '$2 == "London" {print $1, $NF}' scores-table.txt \ No newline at end of file From b0f0fb2ba0f1540af36c5457f3220f1016a15620 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:39:25 +0100 Subject: [PATCH 31/33] Count game attempts per player using field count --- individual-shell-tools/awk/script-05.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-05.sh b/individual-shell-tools/awk/script-05.sh index d1680cb02..0ccc8341f 100755 --- a/individual-shell-tools/awk/script-05.sh +++ b/individual-shell-tools/awk/script-05.sh @@ -5,3 +5,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". +awk '{print $1, NF-2}' scores-table.txt \ No newline at end of file From 7a23a2ba9743da065e0d27bfbcc92f702058406c Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:40:56 +0100 Subject: [PATCH 32/33] Calculate sum of all players' first scores --- individual-shell-tools/awk/script-06-stretch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-06-stretch.sh b/individual-shell-tools/awk/script-06-stretch.sh index 0201e6378..6a268bbeb 100755 --- a/individual-shell-tools/awk/script-06-stretch.sh +++ b/individual-shell-tools/awk/script-06-stretch.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to output the total of adding together all players' first scores. # Your output should be exactly the number 54. +awk '{sum += $3} END {print sum}' scores-table.txt \ No newline at end of file From 7b863faacae6f41ef98e98d2d726fc766bef2c43 Mon Sep 17 00:00:00 2001 From: Joseph Ayitey Date: Fri, 20 Mar 2026 21:42:09 +0100 Subject: [PATCH 33/33] Calculate total scores per player using awk loop --- individual-shell-tools/awk/script-07-stretch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/individual-shell-tools/awk/script-07-stretch.sh b/individual-shell-tools/awk/script-07-stretch.sh index 3f7155880..0e21b17a8 100755 --- a/individual-shell-tools/awk/script-07-stretch.sh +++ b/individual-shell-tools/awk/script-07-stretch.sh @@ -7,3 +7,4 @@ set -euo pipefail # TODO: Write a command to output just the names of each player along with the total of adding all of that player's scores. # Your output should contain 6 lines, each with one word and one number on it. # The first line should be "Ahmed 15". The second line should be "Basia 37" +awk '{sum=0; for(i=3;i<=NF;i++) sum+=$i; print $1, sum}' scores-table.txt \ No newline at end of file