Skip to content

London | 26-SDC-Mar | Craig D'Silva | Sprint 2 | Shell Pipelines#395

Open
craig-dsilva wants to merge 6 commits into
CodeYourFuture:mainfrom
craig-dsilva:shell-pipelines
Open

London | 26-SDC-Mar | Craig D'Silva | Sprint 2 | Shell Pipelines#395
craig-dsilva wants to merge 6 commits into
CodeYourFuture:mainfrom
craig-dsilva:shell-pipelines

Conversation

@craig-dsilva

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes

Changelist

This is the coursework for the Shell pipelines exercise

@craig-dsilva craig-dsilva added 🦑 Size Large 4-8 hours 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Mar 20, 2026

@SlideGauge SlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you add trailing new lines to all the scripts? Doublecheck the settings of your editor, so it will place them automatically.

# TODO: Write a command to show how many times anyone has entered and exited.
# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.

cat events.txt | sort | uniq -c No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It groups by the whole line (person + event type), so the output is 2 Entry German, 1 Entry Mariana, etc. - you have to sum those up yourself to get 5 and 4. The task says it should be clear from the output that there are 5 Entry and 4 Exit events.

# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.
# The word "Event" should not appear in your script's output.

cat events-with-timestamps.txt | awk '{print $3, $4;}' | grep -v 'Event' | sort | uniq -c No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This approach will use awk to extract both event and name, thus leading to similar problem as script-06.sh

# 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 -n -r scores-table.txt No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does -k3 without specifying the end key mean and is it what we want here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The -k flag means to sort by key. By adding 3 to the flag, I'm telling the sort program to sort by the third column.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for explaining what -k3 does — you're right that it selects a sort key. But I was asking something slightly narrower: with -k3 and no end specified, where does that key actually stop? Is it just field 3, or field 3 all the way to the end of the line? Try sort -k3 vs sort -k3,3 on a couple of rows and watch what changes. It happens to give the right answer on this data — but would it still hold if two people had the same first score?

# Piotr Glasgow 15 2 25 11 8
# Chandra Birmingham 12 6

sort -k3 -n -r scores-table.txt | head -n 3 No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does -k3 without specifying the end key mean and is it what we want here?

# TODO: Write a command to output scores-table.txt, with shows the line for the player whose first score was the second highest.
# Your output should be: "Piotr Glasgow 15 2 25 11 8" (without quotes).

sort -k3 -n -r scores-table.txt | head -n 2 | tail -n 1 No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does -k3 without specifying the end key mean and is it what we want here?

Comment thread shell-pipelines/ls-grep/script-03.sh Outdated
# 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.

ls sample-files | grep '^[A-Z]' | grep -vE '.[A-Z]' No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Creative use of piping of greps, like.

@SlideGauge SlideGauge 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 May 3, 2026
@SlideGauge

Copy link
Copy Markdown

Could you apply fixes to the points I described?

@craig-dsilva craig-dsilva added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 8, 2026

@SlideGauge SlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better now, a couple of notes from my sides though

# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.
# The word "Event" should not appear in your script's output.

cat events.txt | awk '{print $1}' | sort | uniq -c | awk '{print $1}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is closer, but two things to check before I mark it resolved.

  1. Which file are you reading? Re-read the TODO at the top of this script and compare it to the cat in your pipeline — are they the same file? There's a reason 07 points at a different input than 06; what's different about that file, and why might it matter here?
  2. Yhe task says it should be clear that there are 5 Entry and 4 Exit events — can you still tell which number is which after your final step? What is that last awk '{print $1}' removing, and do you want it gone?
    Also keep an eye on the "the word Event should not appear" requirement once you switch inputs — that constraint is a hint about what the correct file looks like.

@SlideGauge SlideGauge 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 Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Tools The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 🦑 Size Large 4-8 hours 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants