From 911cd92a3526bee819b9e40f01ecae7a753c78a3 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:19:22 +0000 Subject: [PATCH 01/43] ls --> Implement directory listing in script-01.sh --- individual-shell-tools/ls/script-01.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 241b62f..3e485bf 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,3 +13,5 @@ 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. +cd ../ls +ls \ No newline at end of file From 8b16334fdac506e3c9a46c0f5a30f3e84d4f9348 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:21:11 +0000 Subject: [PATCH 02/43] ls --> Implement file listing in child-directory for script-02.sh --- individual-shell-tools/ls/script-02.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10..b82f218 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,3 +4,5 @@ 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. +cd ../ls/child-directory +ls From f062d6dbbc2322b1fd6cbbfe027fb2901ea0ce20 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:24:41 +0000 Subject: [PATCH 03/43] ls --> Implement recursive file listing in script-03.sh --- individual-shell-tools/ls/script-03.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 781216d..2d88b8a 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,3 +5,5 @@ 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. +cd ../ls +ls -R From 18080a1598ba2f7bfb04fba7ce9b376e4ad25541 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:35:59 +0000 Subject: [PATCH 04/43] ls --> Implement file listing sorted by modification time in script-04.sh --- individual-shell-tools/ls/script-04.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 72f3817..98c0cb3 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -16,6 +16,8 @@ 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. +cd ../ls/child-directory +ls -1t echo "Second exercise (sorted oldest to newest):" From 2798631a1c8da72be6d2dd825fde0bb94e1e3fab Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:39:10 +0000 Subject: [PATCH 05/43] ls --> Implement file listing sorted in the opposite order in script-04.sh --- individual-shell-tools/ls/script-04.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 98c0cb3..a1aff4b 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -23,3 +23,5 @@ 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 -1tr \ No newline at end of file From 8467560a41b134964a4957aeb3d6204a63608c02 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:42:52 +0000 Subject: [PATCH 06/43] cat --> Implement command to output contents of helper-1.txt in script-01.sh --- 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 c85053e..edcc54f 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 ../helper-files/helper-1.txt From 68070ece804b5900af8be339de38e1bb2e6a5053 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:47:02 +0000 Subject: [PATCH 07/43] cat --> Implement command to output contents of all text files in helper-files directory in script-02.sh --- individual-shell-tools/cat/script-02.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 01bbd5e..4e49796 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,3 +11,5 @@ 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/*.txt From 1928e796ac67dc593e5b1b7dcf33ad6bb09215bf Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 10:48:25 +0000 Subject: [PATCH 08/43] cat --> Implement command to output numbered contents of helper-3.txt in script-03.sh --- 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 37573b0..dd6b1d8 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 From 336b8aa4cc10fd23b1d094651b6d24bd164f95e1 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 11:45:53 +0000 Subject: [PATCH 09/43] cat --> Implement command to output numbered contents of all text files in helper-files directory in script-04-stretch.sh --- individual-shell-tools/cat/script-04-stretch.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 00fe3c4..776534f 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,3 +13,5 @@ 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 -n ../helper-files/*.txt From 1211ee7b942acc740255892e0cc17043a156ba28 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 11:51:48 +0000 Subject: [PATCH 10/43] wc --> Implement command to output the number of words in helper-3.txt in script-01.sh --- 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 c9dd6e5..c944eea 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 From 50606f259cf4994065e45fc0a1f7d35a058868e6 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 11:53:03 +0000 Subject: [PATCH 11/43] wc --> Implement command to output the number of lines in helper-3.txt in script-02.sh --- 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 8feeb1a..16e5309 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 From 5bb3577eaa8f484123c6f21480d70d85b873de86 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 11:54:51 +0000 Subject: [PATCH 12/43] wc --> Add command to output word, line, and byte counts for all text files in helper-files directory in script-03.sh --- 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 6b2e9d3..ffe8c57 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/*.txt From c445a6be51dc6c25067b0103fe05dee7506ef5b7 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 11:58:11 +0000 Subject: [PATCH 13/43] grep --> Implement command to output lines spoken by the Doctor in dialogue.txt in script-01.sh --- 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 fb05f42..f26ff9d 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 86617b7727ac85ec1ec034c86ceb9280b38313b4 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:00:33 +0000 Subject: [PATCH 14/43] grep --> Implement command to output lines containing 'Doctor' (regardless of case) from dialogue.txt in script-02.sh --- 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 df6f856..f54298d 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 doctor -i dialogue.txt From 65f3f5b86b7b96adaff5dd13425a7f455ccb6eb3 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:04:53 +0000 Subject: [PATCH 15/43] grep --> Implement command to count lines containing 'Doctor' (case insensitive) in dialogue.txt in script-03.sh --- 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 5383fe5..018edaa 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 doctor -i dialogue.txt | wc -l From ae357f208da96be437e0d3eccc14c6ee8aa97c7a Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:07:09 +0000 Subject: [PATCH 16/43] grep --> Implement command to output lines not containing 'Hello' (case insensitive) from dialogue.txt in script-04.sh --- 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 80ee047..0658ea2 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 hello -iv dialogue.txt From eb4109fb66763e2f2ffce353024ec94e123c71a0 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:13:07 +0000 Subject: [PATCH 17/43] grep --> Implement command to output lines containing 'cure' and the preceding line from dialogue.txt in script-05.sh --- 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 1eb5381..ecf0307 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 cure -B1 dialogue.txt From 988f5f9d26ed49697a08567f2b7fde86dda64c21 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:20:34 +0000 Subject: [PATCH 18/43] grep --> Implement command to output names of .txt files containing lines spoken by the Doctor --- individual-shell-tools/grep/script-06.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 5670e3b..67ecc6e 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -4,3 +4,5 @@ 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 ^Doctor -i *.txt From d47bfbb70560f8b1dae320f830a5985ccd4fc65a Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:34:07 +0000 Subject: [PATCH 19/43] grep --> Update command to output names of .txt files containing lines spoken by the Doctor (case insensitive) --- individual-shell-tools/grep/script-06.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 67ecc6e..da8872b 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -5,4 +5,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 ^Doctor -i *.txt +grep ^Doctor -il *.txt From dc5463521989328e2b7c9686e4d75e49e99d0a9d Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:36:47 +0000 Subject: [PATCH 20/43] grep --> Implement command to count lines of dialogue spoken by the Doctor in all .txt files --- 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 9670eba..cf40f0a 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 ^Doctor -icH *.txt From ec4ce2a46e05be4fb5b3864e4722fdf3a56694e7 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 12:43:00 +0000 Subject: [PATCH 21/43] sed --> Implement command to replace all occurrences of 'i' with 'I' in input.txt using sed --- 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 3eba6fa..328a8e2 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 From 7d99d30de6de1af9b5248a2d790e2dd0f2cbee3c Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 13:40:33 +0000 Subject: [PATCH 22/43] sed --> Implement command to remove all numbers from input.txt in script-02.sh --- 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 abdd64d..afccb32 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 From b79d94d23accef6a1400fdb8f9c88b78b7b88cdd Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 13:47:30 +0000 Subject: [PATCH 23/43] sed --> Implement command to remove lines containing numbers from input.txt in script-03.sh --- 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 dd284a2..e331662 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 -e '/[0-9]/d' input.txt \ No newline at end of file From a7e7ada6be1bcff0ecf3616a0963fdcb07d2b921 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 13:50:49 +0000 Subject: [PATCH 24/43] sed --> Implement command to replace occurrences of "We'll" with "We will" in input.txt in script-04.sh --- 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 0052ac6..4782114 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 08b42da49388ecea3818305c5204fcfb4a04cbfb Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 14:12:16 +0000 Subject: [PATCH 25/43] sed --> Implement command to reorder lines starting with a number in input.txt in script-05.sh --- 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 2dcc91a..a84551d 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 -E 's/^([0-9]+) (.*)$/\2 \1/' input.txt \ No newline at end of file From e195344d7e4aa3511ffd149a28b10bc4db75e77d Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 14:18:42 +0000 Subject: [PATCH 26/43] sed --> Implement command to normalize spaces after commas in input.txt in script-06.sh --- individual-shell-tools/sed/script-06.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 0b93901..ab15800 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -8,3 +8,5 @@ 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 f8f08c58912f5e43fb2086aff29e658e07c595fd Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 14:26:37 +0000 Subject: [PATCH 27/43] awk --> Implement command to output player names from scores-table.txt in script-01.sh --- 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 8db4390..824e4c5 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 \ No newline at end of file From 1e8bf645fc7a4ff3521f55c6feaf414ab17cca1b Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 14:39:00 +0000 Subject: [PATCH 28/43] awk --> Implement command to output player names and their cities in script-02.sh --- 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 5956be9..5559ca2 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 234070e724b79a9f59c6451392bc793b3cdb2c99 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 14:41:50 +0000 Subject: [PATCH 29/43] awk --> Implement command to output player names and their first attempt score in script-03.sh --- individual-shell-tools/awk/script-03.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index af7c6e8..67365bf 100755 --- a/individual-shell-tools/awk/script-03.sh +++ b/individual-shell-tools/awk/script-03.sh @@ -5,3 +5,5 @@ 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 f65408dd71aedef577d4d7ffa20dd2ee3fab3c07 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:03:54 +0000 Subject: [PATCH 30/43] awk --> Output player names in London with their last attempt score in script-04.sh --- individual-shell-tools/awk/script-04.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/individual-shell-tools/awk/script-04.sh b/individual-shell-tools/awk/script-04.sh index bf15703..8c4d18c 100755 --- a/individual-shell-tools/awk/script-04.sh +++ b/individual-shell-tools/awk/script-04.sh @@ -2,6 +2,6 @@ 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". +# Output the names of each player in London along with the score from their last attempt. +# For lines with fewer than 5 columns, print the last column. +awk '{if (NF >= 5 && $2 == "London") print $1, $5; else if (NF < 5 && $2 == "London") print $1, $NF}' scores-table.txt From df28eb6dd475e9795d95445320ef9d4a7ba16038 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:19:04 +0000 Subject: [PATCH 31/43] awk --> Output player names along with their game play counts in script-05.sh --- individual-shell-tools/awk/script-05.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/individual-shell-tools/awk/script-05.sh b/individual-shell-tools/awk/script-05.sh index d1680cb..abdc00c 100755 --- a/individual-shell-tools/awk/script-05.sh +++ b/individual-shell-tools/awk/script-05.sh @@ -2,6 +2,7 @@ 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. +# 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 1a43a45a3cac501474d2bbd2e7d9c9c51c1e9ba7 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:21:09 +0000 Subject: [PATCH 32/43] awk --> Implement command to output the total of all players' first scores in script-06-stretch.sh --- 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 0201e63..fbd9cd9 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 From 779cb977f4165a7575436858ec9fd7237a2506cb Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:37:01 +0000 Subject: [PATCH 33/43] awk --> Implement command to output player names along with the total of their scores in script-07-stretch.sh --- 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 3f71558..3c4bd29 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 '{ for(i = 3; i <= NF; i++) sum += $i; print $1, sum; sum = 0 }' scores-table.txt \ No newline at end of file From 758854324c27129f3ea0617834236cfa7436c816 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:39:57 +0000 Subject: [PATCH 34/43] awk --> update by using the -c flag to count lines containing 'Doctor' in dialogue.txt in script-03.sh --- individual-shell-tools/grep/script-03.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 018edaa..2db2c67 100755 --- a/individual-shell-tools/grep/script-03.sh +++ b/individual-shell-tools/grep/script-03.sh @@ -4,4 +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 doctor -i dialogue.txt | wc -l +grep doctor -ic dialogue.txt \ No newline at end of file From 57158822845d2d24e8c7075932ff43d37de6aaa4 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:42:27 +0000 Subject: [PATCH 35/43] Revert "awk --> Implement command to output player names along with the total of their scores in script-07-stretch.sh" This reverts commit 779cb977f4165a7575436858ec9fd7237a2506cb. --- individual-shell-tools/awk/script-07-stretch.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/individual-shell-tools/awk/script-07-stretch.sh b/individual-shell-tools/awk/script-07-stretch.sh index 3c4bd29..3f71558 100755 --- a/individual-shell-tools/awk/script-07-stretch.sh +++ b/individual-shell-tools/awk/script-07-stretch.sh @@ -7,4 +7,3 @@ 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 '{ for(i = 3; i <= NF; i++) sum += $i; print $1, sum; sum = 0 }' scores-table.txt \ No newline at end of file From 16e8e7968ccb26539ec8eff5b580ba9183b96f76 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:50:34 +0000 Subject: [PATCH 36/43] grep--> Simplify command to count lines containing 'Doctor' in dialogue.txt in script-03.sh --- individual-shell-tools/grep/script-03.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 018edaa..2db2c67 100755 --- a/individual-shell-tools/grep/script-03.sh +++ b/individual-shell-tools/grep/script-03.sh @@ -4,4 +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 doctor -i dialogue.txt | wc -l +grep doctor -ic dialogue.txt \ No newline at end of file From 3bb6a9475361edaebc31b1234dafd013628e7c9a Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Wed, 26 Feb 2025 15:56:24 +0000 Subject: [PATCH 37/43] awk --> Implement command to output player names along with the total of their scores in script-07-stretch.sh --- 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 3f71558..3c4bd29 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 '{ for(i = 3; i <= NF; i++) sum += $i; print $1, sum; sum = 0 }' scores-table.txt \ No newline at end of file From e2abd25d734bf9913f9fb6e0bcb0286cf1fdd36b Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:19:32 +0000 Subject: [PATCH 38/43] cat --> Replace 'cat -n' with 'cat | nl' to number lines in script-03.sh --- individual-shell-tools/cat/script-03.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index dd6b1d8..d4c4c9e 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,4 +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 +cat ../helper-files/helper-3.txt | nl From 3dba76e221259c034fc0575f7264a96b62ddb648 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:20:46 +0000 Subject: [PATCH 39/43] grep --> fix: Adjust grep command syntax for case-insensitive search in script-02.sh --- individual-shell-tools/grep/script-02.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index f54298d..42196a7 100755 --- a/individual-shell-tools/grep/script-02.sh +++ b/individual-shell-tools/grep/script-02.sh @@ -4,4 +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 doctor -i dialogue.txt +grep -i doctor dialogue.txt From c544e75b6ec08edffc22086e6842966ae13b021d Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:27:03 +0000 Subject: [PATCH 40/43] grep --> Fix command to count lines of dialogue for the Doctor in script-07.sh --- individual-shell-tools/grep/script-07.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index cf40f0a..590cd33 100755 --- a/individual-shell-tools/grep/script-07.sh +++ b/individual-shell-tools/grep/script-07.sh @@ -4,4 +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 ^Doctor -icH *.txt +grep ^Doctor -ic *.txt \ No newline at end of file From 7fe9ad0c511c2ddb04bf6b09084f6340b3328fb7 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:32:39 +0000 Subject: [PATCH 41/43] ls --> fix: Simplify directory listing command in script-03.sh by removing unnecessary cd --- individual-shell-tools/ls/script-03.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 2d88b8a..7a1a1d3 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,5 +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. -cd ../ls -ls -R +ls -R \ No newline at end of file From 8828953c3f64e22657be7a2d03983dd0e63089c4 Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:33:24 +0000 Subject: [PATCH 42/43] ls --> fix: Remove unnecessary cd command in script-01.sh for listing files --- individual-shell-tools/ls/script-01.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 3e485bf..0641b0f 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,5 +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. -cd ../ls ls \ No newline at end of file From 697e2107c259ef7826af500198a6c45eae7a070d Mon Sep 17 00:00:00 2001 From: "[Elhadj Abdoul Diallo]" <[elhhabdouldiallo@gmail.com]> Date: Sun, 2 Mar 2025 19:39:30 +0000 Subject: [PATCH 43/43] fix: Use variable for directory path in script-04.sh to improve readability --- individual-shell-tools/ls/script-04.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index a1aff4b..c681377 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -16,12 +16,13 @@ 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. -cd ../ls/child-directory -ls -1t +DIR=../ls/child-directory + +ls -1t $DIR 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 -1tr \ No newline at end of file +ls -1tr $DIR \ No newline at end of file