-
-
Notifications
You must be signed in to change notification settings - Fork 27
ZA | 25-SDC-July | Luke Manyamazi | Sprint 2 | Shell Pipelines Exercises #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ZA | 25-SDC-July | Luke Manyamazi | Sprint 2 | Shell Pipelines Exercises #117
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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]*$'
There was a problem hiding this comment.
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.
Learners, PR Template
Self checklist
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:
Explored tr to transform and clean input data streams, such as converting text to uppercase and replacing whitespace.
Questions