London | SDC-Nov-25| Ikenna Agulobi | sprint 2 | Shell pipelines #250
London | SDC-Nov-25| Ikenna Agulobi | sprint 2 | Shell pipelines #250ike-agu wants to merge 7 commits intoCodeYourFuture:mainfrom
Conversation
DaryaShirokova
left a comment
There was a problem hiding this comment.
Looks good! Just a few comments
|
|
||
| # TODO: Write a command to output the names of the 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 contain 7 files. | ||
|
|
There was a problem hiding this comment.
I think you might have accidentally deleted the line here.
shell-pipelines/ls-grep/script-04.sh
Outdated
| # Your output should be the number 7. | ||
|
|
||
| # ls sample-files | grep "^[A-Z][a-z]*$" | ||
| ls sample-files | grep -c "^[A-Z][a-z]*$" |
There was a problem hiding this comment.
While it is correct in this case, it is not exactly what the exercise asks - for example, it could have numbers / other characters (only uppercase letters need to be excluded)
There was a problem hiding this comment.
@DaryaShirokova I've implemented the fix for this. Thanks for reviewing my PR.
| # TODO: Write a command to output scores-table.txt, with lines sorted by the person's first score, descending. | ||
| # The first line of your output should be "Basia London 22 9 6" (with no quotes). | ||
|
|
||
| sort -k2 -r scores-table.txt |
There was a problem hiding this comment.
The output seems to be:
Basia London 22 9 6
Ahmed London 1 10 4
Leila London 1
Piotr Glasgow 15 2 25 11 8
Mehmet Birmingham 3 12 17
Chandra Birmingham 12 6
Looks like they are not sorted by score?
There was a problem hiding this comment.
I've implemented the fix.
Thank you for the review and for pointing out the error.
|
Hi @DaryaShirokova , thank you for taking the time to review my PR and for pointing out the necessary changes. I’ve implemented all the requested updates. When you have a moment, could you please take another look? |
illicitonion
left a comment
There was a problem hiding this comment.
LGTM - just one question :)
Please what question are you referring? |
|
@illicitonion , Thanks for reviewing my PR. |
| # TODO: Write a command to output scores-table.txt, with lines sorted by the person's first score, descending. | ||
| # The first line of your output should be "Basia London 22 9 6" (with no quotes). | ||
|
|
||
| sort -k3,3 -nr scores-table.txt |
There was a problem hiding this comment.
Can you talk through what the -k3,3 means here, and how it's different from just -k3 that you used in script 3?
There was a problem hiding this comment.
Hi @illicitonion , In my script above, -k3,3 means that the sort key starts and ends at column 3, i.e., only the third column is used for sorting. Meanwhile, -k3 means that the sort key starts at column 3 and continues to the end of the line, so the sorting includes column 3 and all subsequent columns.
There was a problem hiding this comment.
In some of the exercises you've used -k3 and in others -k3,3 even though the questions are phrased the same... Do you think it matters which you use in these cases?
There was a problem hiding this comment.
@illicitonion , Now that I’ve read your question more carefully, I think it does matter. Since the exercise says to sort by the first score, using -k3,3 is more accurate because it limits the sort to just that field. Using -k3 starts at field 3 but includes the rest of the line as part of the key. So for consistency and to match the wording of the exercise, I have updated my script-03.sh exercise to use -k3,3 instead of -k3.
Please let me know if this reasoning is correct. Thanks!
There was a problem hiding this comment.
I think either is probably fine here :) If there's a tie for score, we don't specify how we'd like them sorted (maybe it should be by first name, or by second score, or by the order they were in the file originally), so either -k3 or -k3,3 meets the requirements for the exercise :)
|
@illicitonion , I've responded to your comment on my PR. When you have a moment, could you please take a look? Thank you! |
Learners, PR Template
Self checklist
Changelist
This Pr contains sprint 2 shell pipeline exercise.
Ls-grep exercise:
sort-uniq-head-tail
tr