Skip to content

Conversation

@Luke-Manyamazi
Copy link

@Luke-Manyamazi Luke-Manyamazi commented Jul 23, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Completed the Individual Shell Tools exercises.
Each shell tool in its own folder (awk, cat, grep, ls, sed, wc) with scripts demonstrating how to use each command and combine them effectively. Using $(dirname "$0") for script-relative paths.

#!/bin/bash
set -euo pipefail

The above were already included in the template, but I took time to research and understand what each of them does before continuing.

Questions

Are the solutions clear and readable enough?
Any suggestions for improving how I handle errors or edge cases?

@Luke-Manyamazi Luke-Manyamazi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 23, 2025
@chinar-amrutkar chinar-amrutkar self-requested a review July 23, 2025 16:17
@chinar-amrutkar chinar-amrutkar self-assigned this Jul 23, 2025
@illicitonion illicitonion changed the title ZA | 25-SDC-July | Luke Manyamazi | Sprint 2 | Individual Shell Tools ZA | 25-SDC-July | Luke Manyamazi | Sprint 1 | Individual Shell Tools Jul 24, 2025
@LonMcGregor LonMcGregor removed the request for review from chinar-amrutkar August 11, 2025 09:56
@LonMcGregor LonMcGregor added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 11, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on these tasks - I've left comments on a few of your solutions you could have another go with

# 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:" "$(dirname "$0")"/*.txt | while IFS= read -r filepath; do
basename "$filepath"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -l argument will make it print the filename - why are you using the basename command as well?


# 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:' "$(dirname "$0")"/*.txt | while IFS=: read -r file count; do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you complete this solution using only a single grep command?

# 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 /home/luke/CYF/SDC/Module-Tools/individual-shell-tools/ls/child-directory
ls

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you complete this task without first cd-ing into the directory?

# 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' "$(dirname "$0")/input.txt" | while IFS= read -r line; do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the part of your command after the pipe for this to work?


# 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' "$(dirname "$0")"/input.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how you could rewrite this command to not need so many quote escape sequences?


# 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 "$(dirname "$0")"/../helper-files/helper-3.txt | awk '{print $1}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to pipe to awk here?

# 1 7 39 ../helper-files/helper-2.txt
# 3 19 92 ../helper-files/helper-3.txt
# 5 30 151 total
wc -lwm "$(dirname "$0")"/../helper-files/*.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to give the -lwm arguments here?

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 11, 2025
@Luke-Manyamazi
Copy link
Author

Do you want me to work on these before marking the PR as complete or you are suggesting for me to try them out?

@LonMcGregor
Copy link

@Luke-Manyamazi Yes, could you consider the questions I ask and see if there are changes you could make to the code to address any issues please.

@Luke-Manyamazi
Copy link
Author

Thank you @LonMcGregor I have updated my scripts and they are ready for further review.

@Luke-Manyamazi Luke-Manyamazi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 14, 2025
@LonMcGregor
Copy link

Great work!

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TECH ED] Individual shell tools exercises

3 participants