-
-
Notifications
You must be signed in to change notification settings - Fork 42
Cape Town| 25-SDC-July | Faith Muzondo | Sprint 1 | Individual Shells tools #80
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?
Conversation
OracPrime
left a comment
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.
Almost there! Couple of minor fixes required, along with a general issue that your scripts should work run from the folder they are saved in. So you sometimes need to change things to use relative paths.
| # 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". | ||
|
|
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.
Almost. Your code is giving each player's second score. However the question asks for the last score. Leila only has one score, so you need something slightly different.
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.
I have made changes
|
|
||
| # 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...". | ||
|
|
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.
This sh file could work if it were run in the helper-files directory. However if I run it from here (the cat folder) it doesn't work. How would you make it work from here?
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.
I fixed it. it now runs from the cat directory, may you please chack it for me
| # It looked delicious. | ||
| # I was tempted to take a bite of it. | ||
| # But this seemed like a bad idea... | ||
|
|
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.
Again, this would work if run from the right folder, but in general it's best to make sh files run from where they are in the checkout structure, or from a clearly defined location identified in a comment in the file (e.g. Module-Tools).
| # 2 I was tempted to take a bite of it. | ||
| # 3 But this seemed like a bad idea... | ||
|
|
||
|
|
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.
This needs the same relative path fix as the previous two comments, but otherwise looks good
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.
i fixed it
| # The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0. | ||
|
|
||
| for FILE in *.txt; do | ||
| grep -c "^Doctor" $FILE |
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.
There's a very subtle problem with this. Hints:
- What does
set -euo pipefaildo? - What does
grep -creturn when there are no matches?
That's quite subtle!
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.
There is also a simpler way to do this without a for loop!
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.
the set -euo pipefail is just for good practice. the e is to ensure the script exists immediately if a command fails, the u causes the script to exit immediately if you try to use an unset variable and the o catches errors in a pipeline. I tried the other way under the original. It is a lot easier, thank you
| # 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.". | ||
|
|
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.
Well done, perfect score for sed
|
|
||
| # 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 < helper-files/helper-3.txt |
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.
This has the same relative path problem we had in cat, but is otherwise correct
OracPrime
left a comment
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.
Yup, that all looks good to me, well done.
|
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
|
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). |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.