Skip to content

Conversation

@nadika-zavodovska
Copy link

Hi,

I've done all the tasks for the individual-shell-tools.

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Thank you.

@nadika-zavodovska nadika-zavodovska added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 1 Assigned during Sprint 1 of this module labels Mar 7, 2025
Copy link

@ehwus ehwus left a comment

Choose a reason for hiding this comment

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

Great work Nadika! All of your scripts matched the expected output perfectly, and were all clear and readable. I particularly enjoyed seeing your comments explaining what your commands were actually doing, they were all very sensible additions to make your scripts clearer and more maintainable.


awk '{print $1}' scores-table.txt

# '{print $1}' - output only the names from the first field. No newline at end of file
Copy link

Choose a reason for hiding this comment

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

praise: Great to see your working in the comments here

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!

# TODO: Write a command to output the total of adding together all players' first scores.
# Your output should be exactly the number 54.

awk '{sum += $3} END {print sum}' scores-table.txt
Copy link

Choose a reason for hiding this comment

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

praise: This is a really clear and elegant solution to the problem!

Copy link
Author

Choose a reason for hiding this comment

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

@ehwus Alex, thank you! I really appreciate your feedback!

# Your output should contain 6 lines, each with one word and one number on it.
# The first line should be "Ahmed 15". The second line should be "Basia 37"

awk '{scoreSum = 0; for( i = 3; i <= NF; i++) scoreSum += $i; print $1, scoreSum}' scores-table.txt
Copy link

Choose a reason for hiding this comment

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

question: What would be different if we didn't initialise the scoreSum variable here? Why might that cause unexpected behaviour?

Copy link
Author

Choose a reason for hiding this comment

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

@ehwus Alex, thank you for a great question. If we don’t set scoreSum = 0, it may keep numbers from the line before, which could make the totals incorrect. Setting it to 0 means each player’s score starts from zero, so the result is right.

# I was tempted to take a bite of it.
# But this seemed like a bad idea...

cat ../helper-files/*
Copy link

Choose a reason for hiding this comment

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

praise: Great use of the wildcard here, I'm sure it will come in useful!

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!


grep -i -v "Hello" dialogue.txt

# -v - inverts, return lines that don't contain "Hello" or "hello" No newline at end of file
Copy link

Choose a reason for hiding this comment

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

question: are you sure about which does which here?

Copy link
Author

Choose a reason for hiding this comment

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

@ehwus Alex, I think so. The -i option ignores the case (so it matches "Hello", "hello"), and -v inverts the match, showing lines that don’t contain "Hello".

sed 's/^\([0-9]\+\) \(.*\)$/\2 \1/' input.txt

# \([0-9]\+\ - matches one or more digits.
# \(.*\)$/\2 \1/ - matches the rest of the line (2 - part after digit, 1 - part with digit). No newline at end of file
Copy link

Choose a reason for hiding this comment

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

praise: These explanations in comments become more useful the more complex our code becomes, and the world would be a better place if everyone always left these sorts of comments when they write regular expressions!

Copy link
Author

Choose a reason for hiding this comment

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

@ehwus Alex, thank you so much for your kind comment! I completely agree, well-commented code helps everyone, especially when dealing with complex regular expressions. Your feedback motivates me to keep up the practice!

@ehwus ehwus 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 Mar 16, 2025
@nadika-zavodovska
Copy link
Author

Thank you for the great feedback, @ehwus Alex! I’m glad to hear the scripts worked well. Your encouragement motivates me to keep writing clear, understandable code and adding comments for better maintainability!

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. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants