Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d6ba327
List one file or folder per line
lauracs24 Nov 19, 2026
a03c88f
List the files in the child directory
lauracs24 Nov 19, 2026
2745ab9
List files in subdirectories too
lauracs24 Nov 19, 2026
77a5e50
Sort files newest and oldest first
lauracs24 Nov 19, 2026
d6f0fdc
Print the first helper file
lauracs24 Nov 19, 2026
e3b5ffb
Print all helper files with one cat command
lauracs24 Nov 19, 2026
995b5e8
Number the lines in the third helper file
lauracs24 Nov 20, 2026
3f5c22f
Count the words in the third helper file
lauracs24 Nov 20, 2026
404f1d4
Count the lines in the third helper file
lauracs24 Nov 22, 2026
34d1444
Count lines, words, and characters in the helper files
lauracs24 Nov 22, 2026
764da35
Find the lines spoken by the Doctor
lauracs24 Nov 22, 2026
46ead98
Find mentions of the Doctor
lauracs24 Nov 22, 2026
e89004d
Count lines that mention the Doctor
lauracs24 Nov 22, 2026
ac61e1c
Leave out dialogue lines containing hello
lauracs24 Nov 22, 2026
a9e735f
Show the line before each cure match
lauracs24 Nov 22, 2026
336a18e
Find files with lines spoken by the Doctor
lauracs24 Nov 22, 2026
6887bd1
Count the Doctor's lines in each file
lauracs24 Nov 22, 2026
b064f49
Replace every lowercase i with uppercase I
lauracs24 Nov 22, 2026
bb2adb1
Remove digits from the input
lauracs24 Nov 22, 2026
0e521d3
Drop lines that contain digits
lauracs24 Nov 22, 2026
7316221
Expand We'll to We will
lauracs24 Nov 22, 2026
7968742
Move leading scores to the end of the line
lauracs24 Nov 22, 2026
4c0f7eb
Add missing spaces after commas
lauracs24 Nov 22, 2026
56e2768
Print the names from the score table
lauracs24 Nov 22, 2026
b839103
Print each player alongside their city
lauracs24 Nov 22, 2026
d170632
Print each player with their first score
lauracs24 Nov 22, 2026
d805d23
Show the latest score for London players
lauracs24 Nov 22, 2026
292c823
Count attempts for each player
lauracs24 Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions individual-shell-tools/awk/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# The name comes first on every row, so $1 is all we need.
awk '{print $1}' scores-table.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/awk/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# The city comes right after the name, so print the first two fields.
awk '{print $1, $2}' scores-table.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/awk/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ 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".

# The first score comes after the name and city, so it is in the third field.
awk '{print $1, $3}' scores-table.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/awk/script-04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,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".

# Players can have different numbers of scores, so $NF gets the last one on each row.
awk '$2 == "London" {print $1, $NF}' scores-table.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/awk/script-05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ 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".

# The first two fields are the name and city, so NF - 2 counts just the scores.
awk '{print $1, NF - 2}' scores-table.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/cat/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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...".

# Use ../ because helper-files is next to the cat directory.
cat ../helper-files/helper-1.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/cat/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ set -euo pipefail
# It looked delicious.
# I was tempted to take a bite of it.
# But this seemed like a bad idea...

# Bash expands *.txt into the helper filenames, so cat only needs to run once.
cat ../helper-files/*.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/cat/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ 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...

# The -n flag adds a line number before each line of output.
cat -n ../helper-files/helper-3.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/grep/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ set -euo pipefail

# TODO: Write a command to output every line in dialogue.txt said by the Doctor.
# The output should contain 6 lines.

# Match Doctor: at the start of the line to find the lines spoken by the Doctor.
grep '^Doctor:' dialogue.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/grep/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Both Doctor and doctor should match, even in the middle of a line.
grep -iw 'Doctor' dialogue.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/grep/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Keep the same search and use -c to get the count instead of the dialogue.
grep -ciw 'Doctor' dialogue.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/grep/script-04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Flip the match with -v so lines with either Hello or hello are left out.
grep -ivw 'Hello' dialogue.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/grep/script-05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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).

# Include the previous line with -B 1 so each match has a bit of context.
grep -B 1 'cure' dialogue.txt
4 changes: 4 additions & 0 deletions individual-shell-tools/grep/script-06.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ 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.

# Keep the file order consistent across machines and print just the matching filenames.
export LC_ALL=C
grep -l '^Doctor:' *.txt
4 changes: 4 additions & 0 deletions individual-shell-tools/grep/script-07.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ 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.

export LC_ALL=C
# Use -c to get a count for every file, even when the Doctor has no lines.
grep -c '^Doctor:' *.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/ls/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ 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.

# Use -1 so each file or folder appears on its own line, even in the terminal.
ls -1
3 changes: 3 additions & 0 deletions individual-shell-tools/ls/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Pass child-directory to ls to list its contents without changing directories.
ls -1 child-directory
3 changes: 3 additions & 0 deletions individual-shell-tools/ls/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ 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.

# Use -R to include the contents of each subdirectory in the listing.
ls -1R
5 changes: 5 additions & 0 deletions individual-shell-tools/ls/script-04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ echo "First exercise (sorted newest to oldest):"
# The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt.


# Sort by modification time with -t, then add -r for the oldest-first listing.
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
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ 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.".

# The g flag changes every lowercase i on each line, including repeated ones.
sed 's/i/I/g' input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ 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".

# Replace each digit with nothing so the rest of the line stays as it is.
sed 's/[[:digit:]]//g' input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ set -euo pipefail

# TODO: Write a command to output input.txt removing any line which contains a number.
# The output should contain 6 lines.

# A single digit is enough for d to drop the whole line.
sed '/[[:digit:]]/d' input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Double quotes let the apostrophe in We'll go straight into the pattern.
sed "s/We'll/We will/g" input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ 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.

# Grab the number and the text separately so 37 Alisha becomes Alisha 37.
sed -E 's/^([[:digit:]]+) (.*)$/\2 \1/' input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/sed/script-06.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ 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.".

# Check again after adding spaces so a pair of commas gets fixed too.
sed -E ':space; s/,([^ ])/, \1/g; t space; s/,$/, /' input.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/wc/script-01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# The -w flag asks wc for just the word count.
wc -w ../helper-files/helper-3.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/wc/script-02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ 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.

# Use -l to get the line count for this file.
wc -l ../helper-files/helper-3.txt
3 changes: 3 additions & 0 deletions individual-shell-tools/wc/script-03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ set -euo pipefail
# 1 7 39 ../helper-files/helper-2.txt
# 3 19 92 ../helper-files/helper-3.txt
# 5 30 151 total

# Use -l, -w, and -m to count lines, words, and characters in each file.
wc -lwm ../helper-files/*.txt
Loading