Skip to content

London | 26-SDC-Mar | Craig D'Silva | Sprint 1 | Individual shell tools#368

Open
craig-dsilva wants to merge 6 commits intoCodeYourFuture:mainfrom
craig-dsilva:individual-shell-tools
Open

London | 26-SDC-Mar | Craig D'Silva | Sprint 1 | Individual shell tools#368
craig-dsilva wants to merge 6 commits intoCodeYourFuture:mainfrom
craig-dsilva:individual-shell-tools

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 my coursework for Individual shell tools exercise.

@craig-dsilva craig-dsilva added 🦑 Size Large 4-8 hours 📅 Sprint 1 Assigned during Sprint 1 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 13, 2026
@SlideGauge SlideGauge added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Apr 6, 2026
# 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 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.

  1. What will happen if this pattern faces a line looking like this:
    DoctorImpostor: I'm real!
  2. The task asks to output filenames only. What will happen our case, though?

# TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has.
# The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0.

grep -c ^Doctor *.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.

Same here about the line like:
DoctorImpostor: lalalalala

# TODO: Write a command to output every line in dialogue.txt said by the Doctor.
# The output should contain 6 lines.

grep ^Doctor dialogue.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 will happen with the line like:
DoctorHouse: la la la

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

awk '{ score += $3 } END { print score }' 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.

good name for the variable name, self-descriptive, like

# Your output should contain 3 lines, each with one word and one number on it.
# The first line should be "Ahmed 4".

awk '{if ($2 == "London") print $1, $NF}' 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.

Correct use of NF, like

# TODO: Write a command which lists the files in the child-directory directory, one per line, sorted so that the most recently modified file is first.
# The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt.

ls child-directory -t
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Whilst it indeed produces what is asked, do we have a way explicitly tell ls to output list of names one per line?

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

cat ../helper-files/helper-3.txt -n 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 won't affect the result in this case, but just for clarity, it is better to pass options (i.e. -n) before filenames.
Typically the format of usage is
command [options] [filenames]

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

cat ../helper-files/*.txt -n 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 won't affect the result in this case, but just for clarity, it is better to pass options (i.e. -n) before filenames.

@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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Apr 6, 2026
@SlideGauge
Copy link
Copy Markdown

Overall good job, could you address my notes please?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants