Skip to content

West Midlands | SDC-July | Gabriel Deng | Sprint 2 | Jq-Exercises#109

Open
gai93003 wants to merge 8 commits intoCodeYourFuture:mainfrom
gai93003:jq_exercises
Open

West Midlands | SDC-July | Gabriel Deng | Sprint 2 | Jq-Exercises#109
gai93003 wants to merge 8 commits intoCodeYourFuture:mainfrom
gai93003:jq_exercises

Conversation

@gai93003
Copy link

@gai93003 gai93003 commented Jul 21, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@gai93003 gai93003 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 21, 2025
@DaryaShirokova DaryaShirokova added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 9, 2025
@DaryaShirokova DaryaShirokova self-assigned this Aug 9, 2025
# It looked delicious.
# I was tempted to take a bite of it.
# But this seemed like a bad idea...
cat -A ../helper-files/*.txt No newline at end of file

Choose a reason for hiding this comment

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

Just a note: -A shows some invisible characters like $ at the end of the line, it was not necessary here.


# TODO: Write a command to output every line in dialogue.txt that contains the string "cure", as well as the line before that line.
# The output should contain two pairs of two lines of text (with a separator between them).
grep 'cure' < dialogue.txt No newline at end of file

Choose a reason for hiding this comment

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

You would need to use an option here to show the line before the line containing cure. Hint: check out https://man7.org/linux/man-pages/man1/grep.1.html (-B)


# TODO: Write a command to output the name of every `.txt` file in this directory which contains a line of dialogue said by the Doctor.
# The output should contain two filenames.
grep '^Doctor' *.txt

Choose a reason for hiding this comment

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

Almost, you could also just print the file names. Check out --files-with-matches here: https://man7.org/linux/man-pages/man1/grep.1.html

# 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.".
sed 's/, \(^ \) /, /1' input.txt No newline at end of file

Choose a reason for hiding this comment

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

This doesn't add a space after the comma in the line 11, could you please double check?

# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
# Your output should contain 6 lines, each with one word and one number on it.
# The first line should be "Ahmed 3" with no quotes.
jq '.[] | "\(.name) \(.scores | length)"' scores.json No newline at end of file

Choose a reason for hiding this comment

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

Almost! There should be no quotes, I am getting this:

$ jq '.[] | "\(.name) \(.scores | length)"' scores.json
"Ahmed 3"
"Basia 3"
"Mehmet 3"
"Leila 1"
"Piotr 5"
"Chandra 2"

# TODO: Write a command to output just the names of each player along with the total scores from all of their games added together.
# Your output should contain 6 lines, each with one word and one number on it.
# The first line should be "Ahmed 15" with no quotes.
jq '.[] | "\(.name) \(.scores | add)"' scores.json No newline at end of file

Choose a reason for hiding this comment

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

Same thing with quotes.


Convert the decimal number 14 to binary.
Answer:
Answer: 1110.

Choose a reason for hiding this comment

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

Could you please submit this as a separate PR if possible? One task per pr, I think jq was also a separate one :)

@DaryaShirokova DaryaShirokova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 9, 2025
@gai93003 gai93003 added the Complete Volunteer to add when work is complete and all review comments have been addressed. label Jan 12, 2026
@github-actions
Copy link

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).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants