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

Practiced listing and filtering files using ls and grep, including matching patterns and using extended regular expressions
Used sort, uniq, head, and tail to process text files like scores-table.txt and events-with-timestamps.txt:

  • Sorted lines by specific fields (e.g., person names).
  • Counted unique entries and exits using a combination of tools.
  • Extracted top/bottom lines of sorted data for analysis.
    Explored tr to transform and clean input data streams, such as converting text to uppercase and replacing whitespace.

Questions

  1. Is my usage of sort -k to sort by names correct and efficient, especially for larger datasets?
  2. Are there more concise ways to combine uniq and awk to get counts for multiple patterns (like Entry/Exit) more elegantly?

@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
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.

Hi, good work. I have one comment in task 4 of ls-grep for you to review. Also, can you try to complete the sort-uniq tasks without using grep?


# TODO: Write a command to count the number of files in the sample-files directory whose name starts with an upper case letter and doesn't contain any other upper case letters.
# Your output should be the number 7.
ls sample-files | grep -E '^[A-Z]$|^[A-Z][a-z]*$' | wc -l

Choose a reason for hiding this comment

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

Do you know of any arguments for grep that would let you count without needing to pipe into wc?

Copy link
Author

Choose a reason for hiding this comment

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

From the research I did, it seems that non-standard versions of grep, like GNU grep, support the -c option, which counts the number of matching lines.

I could use a regex together with grep -c as an argument, as below:

ls sample-files | grep -c -E '^[A-Z]$|^[A-Z][a-z]*$'

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, @LonMcGregor, for reviewing my exercises. I really appreciate your feedback and guidance.

@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 Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review with trainee action still to take.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TECH ED] Shell pipelines exercises
2 participants