From 21034160f3f0389a6333c7638b2b48d47a47d2df Mon Sep 17 00:00:00 2001 From: mervereis Date: Mon, 13 Jul 2026 22:33:28 +0100 Subject: [PATCH 1/4] Add commands to text files with awk, grep, sed, and wc --- individual-shell-tools/awk/script-01.sh | 2 ++ individual-shell-tools/awk/script-02.sh | 1 + individual-shell-tools/awk/script-03.sh | 1 + individual-shell-tools/awk/script-04.sh | 1 + individual-shell-tools/awk/script-05.sh | 1 + individual-shell-tools/cat/script-01.sh | 6 ++++++ individual-shell-tools/cat/script-02.sh | 15 +++++++++++++++ individual-shell-tools/cat/script-03.sh | 5 +++++ individual-shell-tools/grep/script-01.sh | 1 + individual-shell-tools/grep/script-02.sh | 1 + individual-shell-tools/grep/script-03.sh | 1 + individual-shell-tools/grep/script-04.sh | 1 + individual-shell-tools/grep/script-05.sh | 1 + individual-shell-tools/grep/script-06.sh | 1 + individual-shell-tools/grep/script-07.sh | 1 + individual-shell-tools/ls/script-01.sh | 1 + individual-shell-tools/ls/script-02.sh | 1 + individual-shell-tools/ls/script-03.sh | 1 + individual-shell-tools/ls/script-04.sh | 2 ++ individual-shell-tools/sed/script-01.sh | 1 + individual-shell-tools/sed/script-02.sh | 1 + individual-shell-tools/sed/script-03.sh | 1 + individual-shell-tools/sed/script-04.sh | 1 + individual-shell-tools/sed/script-05.sh | 1 + individual-shell-tools/sed/script-06.sh | 1 + individual-shell-tools/wc/script-01.sh | 1 + individual-shell-tools/wc/script-02.sh | 1 + individual-shell-tools/wc/script-03.sh | 1 + 28 files changed, 53 insertions(+) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 8db4390af..02aa73512 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -4,3 +4,5 @@ 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 diff --git a/individual-shell-tools/awk/script-02.sh b/individual-shell-tools/awk/script-02.sh index 5956be9bd..86ccd594f 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 diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index af7c6e8b9..19cabaa3a 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 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 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 diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index c85053e0f..da2eb60f0 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,3 +4,9 @@ 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...". + +//mkdir helper-files +//cd helper-files +//cat > helper-1.txt +//Once upon a time... +//press the return key and then control+D diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 01bbd5eab..f5eae7526 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,3 +11,18 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... + + +//cat > helper-2.txt +There was a house made of gingerbread. +//cat > helper-3.txt +It looked delicious. +// cat > helper-4.txt +I was tempted to take a bite of it. +// cat >helper-5.txt +But this seemed like a bad idea... +// helper-files % cd .. +// % cat helper-files/* +There was a house made of gingerbread.It looked delicious. +I was tempted to take a bite of it. +But this seemed like a bad idea... \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index 37573b0c1..0fcfaa5fc 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,3 +9,8 @@ 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... + +// cd helper-files +// helper-files % cat -n helper-3.txt + 1 It looked delicious. + diff --git a/individual-shell-tools/grep/script-01.sh b/individual-shell-tools/grep/script-01.sh index fb05f42f2..5ad8b8562 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 diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index df6f85640..ab96f7d28 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 diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 5383fe578..03a6b64f2 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 -i 'Doctor' dialogue.txt | wc -l \ No newline at end of file diff --git a/individual-shell-tools/grep/script-04.sh b/individual-shell-tools/grep/script-04.sh index 80ee04776..f0af2fd4d 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 -vi 'Hello' dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index 1eb538185..af9ec9b67 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 -B 1 'cure' dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 5670e3b6c..1a58416f6 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 diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index 9670ebad9..e57c3bdc3 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 diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 241b62f5e..02f6edcc5 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 diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10f4..a5579e1ca 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 child-directory diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 781216d21..7a1a1d315 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 \ No newline at end of file diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 72f3817b3..f45b5b740 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -15,9 +15,11 @@ 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 -1t 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 -1tr child-directory \ No newline at end of file diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index d592970fc..a66b43d5b 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 diff --git a/individual-shell-tools/sed/script-02.sh b/individual-shell-tools/sed/script-02.sh index abdd64d06..e7f45e060 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 diff --git a/individual-shell-tools/sed/script-03.sh b/individual-shell-tools/sed/script-03.sh index dd284a296..cf634a1e1 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 diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 0052ac6c4..4acf3f248 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 diff --git a/individual-shell-tools/sed/script-05.sh b/individual-shell-tools/sed/script-05.sh index 2dcc91a0c..6aed68b08 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 diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 0b9390170..7d5227c6f 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/,\([^ ]\)/, \1/g' input.txt diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index c9dd6e5df..476ae7cf0 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 diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index 8feeb1a62..b62b45fb6 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 diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index 6b2e9d3d1..ceaeaa1e3 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/* From 79e87742240a7334d230d69df21d28e6014e04ab Mon Sep 17 00:00:00 2001 From: mervereis Date: Mon, 13 Jul 2026 22:45:13 +0100 Subject: [PATCH 2/4] Fix command syntax in various scripts by removing comment slashes --- individual-shell-tools/awk/script-01.sh | 2 +- individual-shell-tools/awk/script-02.sh | 2 +- individual-shell-tools/awk/script-03.sh | 2 +- individual-shell-tools/cat/script-01.sh | 10 +++++----- individual-shell-tools/cat/script-02.sh | 12 ++++++------ individual-shell-tools/cat/script-03.sh | 4 ++-- individual-shell-tools/grep/script-01.sh | 2 +- individual-shell-tools/grep/script-02.sh | 2 +- individual-shell-tools/grep/script-03.sh | 2 +- individual-shell-tools/grep/script-04.sh | 2 +- individual-shell-tools/grep/script-05.sh | 2 +- individual-shell-tools/grep/script-06.sh | 2 +- individual-shell-tools/grep/script-07.sh | 2 +- individual-shell-tools/ls/script-01.sh | 2 +- individual-shell-tools/ls/script-02.sh | 2 +- individual-shell-tools/ls/script-04.sh | 4 ++-- individual-shell-tools/sed/script-01.sh | 2 +- individual-shell-tools/sed/script-02.sh | 2 +- individual-shell-tools/sed/script-03.sh | 2 +- individual-shell-tools/sed/script-04.sh | 2 +- individual-shell-tools/sed/script-05.sh | 2 +- individual-shell-tools/sed/script-06.sh | 2 +- individual-shell-tools/wc/script-01.sh | 2 +- individual-shell-tools/wc/script-02.sh | 2 +- individual-shell-tools/wc/script-03.sh | 2 +- 25 files changed, 36 insertions(+), 36 deletions(-) diff --git a/individual-shell-tools/awk/script-01.sh b/individual-shell-tools/awk/script-01.sh index 02aa73512..e75a263cf 100755 --- a/individual-shell-tools/awk/script-01.sh +++ b/individual-shell-tools/awk/script-01.sh @@ -5,4 +5,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 +awk '{print $1}' scores-table.txt diff --git a/individual-shell-tools/awk/script-02.sh b/individual-shell-tools/awk/script-02.sh index 86ccd594f..da34660ab 100755 --- a/individual-shell-tools/awk/script-02.sh +++ b/individual-shell-tools/awk/script-02.sh @@ -4,4 +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 +awk '{print $1, $2}' scores-table.txt diff --git a/individual-shell-tools/awk/script-03.sh b/individual-shell-tools/awk/script-03.sh index 19cabaa3a..87c511f6e 100755 --- a/individual-shell-tools/awk/script-03.sh +++ b/individual-shell-tools/awk/script-03.sh @@ -5,4 +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 +awk '{print $1, $3}' scores-table.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index da2eb60f0..22a9dde9e 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -5,8 +5,8 @@ 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...". -//mkdir helper-files -//cd helper-files -//cat > helper-1.txt -//Once upon a time... -//press the return key and then control+D +mkdir helper-files +cd helper-files +cat > helper-1.txt +Once upon a time... +press the return key and then control+D diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index f5eae7526..4ba914d12 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -13,16 +13,16 @@ set -euo pipefail # But this seemed like a bad idea... -//cat > helper-2.txt +cat > helper-2.txt There was a house made of gingerbread. -//cat > helper-3.txt +cat > helper-3.txt It looked delicious. -// cat > helper-4.txt + cat > helper-4.txt I was tempted to take a bite of it. -// cat >helper-5.txt + cat >helper-5.txt But this seemed like a bad idea... -// helper-files % cd .. -// % cat helper-files/* +helper-files % cd .. + % cat helper-files/* There was a house made of gingerbread.It looked delicious. I was tempted to take a bite of it. But this seemed like a bad idea... \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index 0fcfaa5fc..bee46dbce 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -10,7 +10,7 @@ set -euo pipefail # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... -// cd helper-files -// helper-files % cat -n helper-3.txt + cd helper-files + helper-files % cat -n helper-3.txt 1 It looked delicious. diff --git a/individual-shell-tools/grep/script-01.sh b/individual-shell-tools/grep/script-01.sh index 5ad8b8562..2e212714b 100755 --- a/individual-shell-tools/grep/script-01.sh +++ b/individual-shell-tools/grep/script-01.sh @@ -4,4 +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 +grep '^Doctor:' dialogue.txt diff --git a/individual-shell-tools/grep/script-02.sh b/individual-shell-tools/grep/script-02.sh index ab96f7d28..53a4d54db 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 -i 'Doctor' dialogue.txt +grep -i 'Doctor' dialogue.txt diff --git a/individual-shell-tools/grep/script-03.sh b/individual-shell-tools/grep/script-03.sh index 03a6b64f2..d148edbdc 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 -i 'Doctor' dialogue.txt | wc -l \ No newline at end of file +grep -i 'Doctor' dialogue.txt | wc -l \ No newline at end of file diff --git a/individual-shell-tools/grep/script-04.sh b/individual-shell-tools/grep/script-04.sh index f0af2fd4d..8331c60af 100755 --- a/individual-shell-tools/grep/script-04.sh +++ b/individual-shell-tools/grep/script-04.sh @@ -4,4 +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 -vi 'Hello' dialogue.txt \ No newline at end of file +grep -vi 'Hello' dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-05.sh b/individual-shell-tools/grep/script-05.sh index af9ec9b67..af4a285b9 100755 --- a/individual-shell-tools/grep/script-05.sh +++ b/individual-shell-tools/grep/script-05.sh @@ -4,4 +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 -B 1 'cure' dialogue.txt \ No newline at end of file +grep -B 1 'cure' dialogue.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-06.sh b/individual-shell-tools/grep/script-06.sh index 1a58416f6..0e6d14126 100755 --- a/individual-shell-tools/grep/script-06.sh +++ b/individual-shell-tools/grep/script-06.sh @@ -4,4 +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 +grep -l '^Doctor:' *.txt \ No newline at end of file diff --git a/individual-shell-tools/grep/script-07.sh b/individual-shell-tools/grep/script-07.sh index e57c3bdc3..5f037b5c6 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 -c '^Doctor:' *.txt \ No newline at end of file +grep -c '^Doctor:' *.txt \ No newline at end of file diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 02f6edcc5..0641b0f3f 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,4 +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 +ls \ No newline at end of file diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index a5579e1ca..d37175729 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 child-directory +ls child-directory diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index f45b5b740..72612a865 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -15,11 +15,11 @@ 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 -1t child-directory +ls -1t 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 -1tr child-directory \ No newline at end of file +ls -1tr child-directory \ No newline at end of file diff --git a/individual-shell-tools/sed/script-01.sh b/individual-shell-tools/sed/script-01.sh index a66b43d5b..6255a124b 100755 --- a/individual-shell-tools/sed/script-01.sh +++ b/individual-shell-tools/sed/script-01.sh @@ -5,4 +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 +sed 's/i/I/g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-02.sh b/individual-shell-tools/sed/script-02.sh index e7f45e060..d3f70b8ce 100755 --- a/individual-shell-tools/sed/script-02.sh +++ b/individual-shell-tools/sed/script-02.sh @@ -5,4 +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 +sed 's/[0-9]//g' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-03.sh b/individual-shell-tools/sed/script-03.sh index cf634a1e1..02b29409e 100755 --- a/individual-shell-tools/sed/script-03.sh +++ b/individual-shell-tools/sed/script-03.sh @@ -4,4 +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 +sed '/[0-9]/d' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 4acf3f248..478211422 100755 --- a/individual-shell-tools/sed/script-04.sh +++ b/individual-shell-tools/sed/script-04.sh @@ -4,4 +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 +sed "s/We'll/We will/g" input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-05.sh b/individual-shell-tools/sed/script-05.sh index 6aed68b08..895d62b9e 100755 --- a/individual-shell-tools/sed/script-05.sh +++ b/individual-shell-tools/sed/script-05.sh @@ -6,4 +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 +sed 's/^\([0-9]\+\) \(.*\)$/\2 \1/' input.txt \ No newline at end of file diff --git a/individual-shell-tools/sed/script-06.sh b/individual-shell-tools/sed/script-06.sh index 7d5227c6f..9331f9074 100755 --- a/individual-shell-tools/sed/script-06.sh +++ b/individual-shell-tools/sed/script-06.sh @@ -8,4 +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/,\([^ ]\)/, \1/g' input.txt +sed 's/,\([^ ]\)/, \1/g' input.txt diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index 476ae7cf0..25e5bcb2e 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -4,4 +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 +wc -w helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index b62b45fb6..095e380ab 100755 --- a/individual-shell-tools/wc/script-02.sh +++ b/individual-shell-tools/wc/script-02.sh @@ -4,4 +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 +wc -l helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index ceaeaa1e3..3c600b069 100755 --- a/individual-shell-tools/wc/script-03.sh +++ b/individual-shell-tools/wc/script-03.sh @@ -8,4 +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/* +wc helper-files/* From 1a6c2149d80518f0961de8cb879ee0747af9f2a6 Mon Sep 17 00:00:00 2001 From: mervereis Date: Mon, 13 Jul 2026 22:53:02 +0100 Subject: [PATCH 3/4] Refactor file paths in scripts to use relative paths for helper files --- individual-shell-tools/cat/script-01.sh | 6 +----- individual-shell-tools/cat/script-02.sh | 14 +------------- individual-shell-tools/cat/script-03.sh | 6 +++--- individual-shell-tools/wc/script-01.sh | 2 +- individual-shell-tools/wc/script-02.sh | 2 +- individual-shell-tools/wc/script-03.sh | 3 ++- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index 22a9dde9e..da5ec5029 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -5,8 +5,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...". -mkdir helper-files -cd helper-files -cat > helper-1.txt -Once upon a time... -press the return key and then control+D +cat ../helper-files/helper-1.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 4ba914d12..258ad3010 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -13,16 +13,4 @@ set -euo pipefail # But this seemed like a bad idea... -cat > helper-2.txt -There was a house made of gingerbread. -cat > helper-3.txt -It looked delicious. - cat > helper-4.txt -I was tempted to take a bite of it. - cat >helper-5.txt -But this seemed like a bad idea... -helper-files % cd .. - % cat helper-files/* -There was a house made of gingerbread.It looked delicious. -I was tempted to take a bite of it. -But this seemed like a bad idea... \ No newline at end of file +cat ../helper-files/* \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index bee46dbce..46399b359 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -10,7 +10,7 @@ set -euo pipefail # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... - cd helper-files - helper-files % cat -n helper-3.txt - 1 It looked delicious. + +cat -n ../helper-files/helper-3.txt + diff --git a/individual-shell-tools/wc/script-01.sh b/individual-shell-tools/wc/script-01.sh index 25e5bcb2e..c944eeafe 100755 --- a/individual-shell-tools/wc/script-01.sh +++ b/individual-shell-tools/wc/script-01.sh @@ -4,4 +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 +wc -w ../helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-02.sh b/individual-shell-tools/wc/script-02.sh index 095e380ab..16e530918 100755 --- a/individual-shell-tools/wc/script-02.sh +++ b/individual-shell-tools/wc/script-02.sh @@ -4,4 +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 +wc -l ../helper-files/helper-3.txt diff --git a/individual-shell-tools/wc/script-03.sh b/individual-shell-tools/wc/script-03.sh index 3c600b069..45682002b 100755 --- a/individual-shell-tools/wc/script-03.sh +++ b/individual-shell-tools/wc/script-03.sh @@ -8,4 +8,5 @@ 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/* + +wc ../helper-files/* From 47eaf6af6ddd139890893ef16fc3646a3b23dc0c Mon Sep 17 00:00:00 2001 From: mervereis Date: Mon, 13 Jul 2026 22:58:01 +0100 Subject: [PATCH 4/4] Fix sed command to correctly replace "We'll" with "We will" in input.txt --- individual-shell-tools/sed/script-04.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/individual-shell-tools/sed/script-04.sh b/individual-shell-tools/sed/script-04.sh index 478211422..3917c9dde 100755 --- a/individual-shell-tools/sed/script-04.sh +++ b/individual-shell-tools/sed/script-04.sh @@ -4,4 +4,5 @@ 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 + +sed "s/ We'll/ We will/g" input.txt \ No newline at end of file