-
-
Notifications
You must be signed in to change notification settings - Fork 83
London | 26-SDC-Mar | Beko | Sprint 1 | Individual shell tools exercises #352
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
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 |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| awk '/London/ {print $1, $4}' 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. What happens when we meet lines with different number of scores? 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. What will happen if some of the player's have name "London" but the city is not London? |
||
|
|
||
| # 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". | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| awk '{for (i=3; i<=NF; i++) sum[$1] += $i} END {for (name in sum) print name, sum[name]}' 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. Does |
||
|
|
||
| # NOTE: This is a stretch exercise - it is optional. | ||
|
|
||
| # TODO: Write a command to output just the names of each player along with the total of adding all of that player's scores. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,8 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
|
|
||
| grep -v "Hello" 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 it find lines like "hello" (lowercase)? |
||
|
|
||
| # TODO: Write a command to output every line in dialogue.txt that does not contain the word "Hello" (regardless of case). | ||
| # The output should contain 10 lines. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,7 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| grep -l "Doctor:" *.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 it output only lines of the Doctor or can it potentially output lines which contain "Doctor:" somewhere in the middle? |
||
|
|
||
| # 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,5 @@ fi | |
|
|
||
| # TODO: Write a command to list the files and folders in this directory. | ||
| # The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. | ||
|
|
||
| ls ../ls | ||
|
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. README file says |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ set -euo pipefail | |
|
|
||
| # TODO: Write a command which lists all of the files in the directory named child-directory. | ||
| # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. | ||
|
|
||
| ls ../ls/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. README file says |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,5 @@ set -euo pipefail | |
| # TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders. | ||
| # The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more). | ||
| # The formatting of the output doesn't matter. | ||
|
|
||
| ls ../ls ../ls/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. README file says 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. Also, will it output directories contents recursively? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,12 @@ sleep 1 | |
| touch "${script_dir}/child-directory/helper-3.txt" | ||
|
|
||
| echo "First exercise (sorted newest to oldest):" | ||
|
|
||
| ls -t ../ls/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. README file says |
||
| # 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. | ||
|
|
||
|
|
||
| echo "Second exercise (sorted oldest to newest):" | ||
|
|
||
| ls -tr ../ls/child-directory | ||
| # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). | ||
| # 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.
What does NF mean in this context and what will this line output?