Skip to content

Manchester | 25-SDC-Nov | Rahwa Haile | Sprint 1 | Individual shell tools#198

Open
RahwaZeslusHaile wants to merge 13 commits intoCodeYourFuture:mainfrom
RahwaZeslusHaile:individual-shell-tools
Open

Manchester | 25-SDC-Nov | Rahwa Haile | Sprint 1 | Individual shell tools#198
RahwaZeslusHaile wants to merge 13 commits intoCodeYourFuture:mainfrom
RahwaZeslusHaile:individual-shell-tools

Conversation

@RahwaZeslusHaile
Copy link

@RahwaZeslusHaile RahwaZeslusHaile commented Nov 9, 2025

Manchester | 25-SDC-Nov | Rahwa Haile | Sprint 1 | Individual Shell Tools

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Completed exercises using core shell tools:
    • Used ls and ls -R to list files and directories
    • Used cat and wc to inspect file content and counts
    • Used grep to filter lines in files
    • Used sed to edit text and transform lines
    • Used awk to extract specific fields from structured data
  • All script files updated to include working commands.
  • Verified outputs match the expected results.

Question

Could you please review my solutions and let me know if there is anything I can improve, especially in terms of Bash command efficiency or clarity?

@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@RahwaZeslusHaile RahwaZeslusHaile added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

3 similar comments
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

1 similar comment
@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

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 start on this sprint's tasks, I have spotted a few areas where you could improve code further

To answer your question: I can't see any issues with efficiency here


# 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" No newline at end of file

Choose a reason for hiding this comment

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

Why do you use the "quotes" here?

Copy link
Author

Choose a reason for hiding this comment

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

I add quotes for safety, because if the folder name ever contains spaces or special characters, the shell will interpret it incorrectly. Without quotes, a name with spaces would be treated as separate arguments and cause errors.

Choose a reason for hiding this comment

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

Good answer

# 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/^[[:space:]]*([0-9]+)[[:space:]]+(.*)$/\2 \1/" input.txt No newline at end of file

Choose a reason for hiding this comment

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

Do you need to specify [[:space:]] in this manner to match on spaces?

Copy link
Author

Choose a reason for hiding this comment

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

I added [[:space:]] in the sed command for safety because it matches any whitespace character (spaces or tabs). For my input, which only contains spaces, it wasn’t strictly necessary, but using [[:space:]] makes the command more robust and portable for files that might contain tabs or mixed whitespace.

Choose a reason for hiding this comment

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

Thanks for clarifying, it's good you know these different methods that can help depending on the input

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 19, 2025
@RahwaZeslusHaile
Copy link
Author

@LonMcGregor Thanks for the feedback! I’ve updated the sed command to swap numbers and names correctly and simplified it for the current input.

@LonMcGregor
Copy link

This looks complete now, well done

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Dec 1, 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.

2 participants