-
-
Notifications
You must be signed in to change notification settings - Fork 88
London | 26-SDC-Mar | Mariia Serhiienko | Sprint 1 | Individual shell tools #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4206e6d
7c69346
58898fb
da160a6
f3859d8
1fa6968
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ set -euo pipefail | |
| # TODO: Write a command to output just the names of each player along with the score from their first attempt. | ||
| # Your output should contain 6 lines, each with one word and one number on it. | ||
| # The first line should be "Ahmed 1". | ||
| awk '{ print $1, $3 }' scores-table.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing new line is absent |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ set -euo pipefail | |
| # TODO: Write a command to output just the names of each player in London along with the score from their last attempt. | ||
| # Your output should contain 3 lines, each with one word and one number on it. | ||
| # The first line should be "Ahmed 4". | ||
| awk '$2 == "London" { print $1, $NF }' scores-table.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing new line is absent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct use of NF, like |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ set -euo pipefail | |
|
|
||
| # 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing new line is absent |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ set -euo pipefail | |
| # TODO: Write a command to output just the names of each player along with the total of adding all of that player's scores. | ||
| # 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 '{ sum=0; for (i=3; i<=NF; i++) sum += $i; print $1, sum }' scores-table.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing new line is absent |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ set -euo pipefail | |
| # NOTE: This is a stretch exercise - it is optional. | ||
|
|
||
| # TODO: Write a command to output the contents of all of the files in the helper-files directory to the terminal. | ||
| cat -n helper-files/* | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this approach avoid resetting of line numbers at the start of each file? |
||
| # We also want to see the line numbers in the output, but we want line numbers not to reset at the start of each file. | ||
| # | ||
| # The output of this command should be something like: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ | |
| set -euo pipefail | ||
|
|
||
| # TODO: Write a command to output every line in dialogue.txt that contains the word Doctor (regardless of case). | ||
| grep -iw 'doctor' dialogue.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this pattern accept lines like "Doctor:"? |
||
| # The output should contain 9 lines. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ | |
| set -euo pipefail | ||
|
|
||
| # TODO: Write a command to output the number of lines in dialogue.txt that contain the word Doctor (regardless of case). | ||
| grep -iw 'doctor' dialogue.txt | wc -l | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this pattern accept lines like "Doctor:"? |
||
| # The output should be exactly the number 9. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ | |
| set -euo pipefail | ||
|
|
||
| # TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has. | ||
| grep -c '^Doctor:' dialogue.txt dialogue-2.txt dialogue-3.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to hardcode all the file names if the task asks to output for each file in the directory? |
||
| # The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,12 @@ touch "${script_dir}/child-directory/helper-3.txt" | |
| echo "First exercise (sorted newest to oldest):" | ||
|
|
||
| # 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. | ||
| ls -lt child-directory | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this approach give us filenames only? |
||
| # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. | ||
|
|
||
|
|
||
| echo "Second exercise (sorted oldest to newest):" | ||
|
|
||
| # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). | ||
| ls -ltr child-directory | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this approach give us filenames only? |
||
| # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing new line is absent