Cape Town| 25-SDC-July | Faith Muzondo | Sprint 1 | Individual Shells tools#80
Cape Town| 25-SDC-July | Faith Muzondo | Sprint 1 | Individual Shells tools#80Faithy4444 wants to merge 8 commits intoCodeYourFuture:mainfrom
Conversation
OracPrime
left a comment
There was a problem hiding this comment.
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.
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.
|
|
||
| # 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.
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.
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.
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.
This needs the same relative path fix as the previous two comments, but otherwise looks good
| # 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.
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.
There is also a simpler way to do this without a for loop!
There was a problem hiding this comment.
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.". | ||
|
|
|
|
||
| # 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 No newline at end of file |
There was a problem hiding this comment.
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.
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.