-
-
Notifications
You must be signed in to change notification settings - Fork 85
NW | 2026-mar-sdc | Zabihollah Namazi | Sprint 1 | individual-shell-tools-exercises #365
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
1eb1a56
cc96f10
834a111
1530f68
81a2a7d
dfc8887
f961b0f
7a65b90
450273d
73d6725
4681b06
e32e39e
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 |
|---|---|---|
|
|
@@ -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. Correct start from 3, skipping unnecessary fields, like! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ set -euo pipefail | |
|
|
||
| # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. | ||
| # The output of this command should be "Once upon a time...". | ||
| cyf@MacBookPro individual-shell-tools % cat helper-files/helper-1.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 will happen if I try to execute this script as it is written right now? with cyf@MacBookPro etc? |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ set -euo pipefail | |
| # It looked delicious. | ||
| # I was tempted to take a bite of it. | ||
| # But this seemed like a bad idea... | ||
| cyf@MacBookPro individual-shell-tools % cat helper-files/helper-*.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. Same here, what will happen if I try to execute this script as it is written right now? with cyf@MacBookPro etc? |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ set -euo pipefail | |
| # 1 It looked delicious. | ||
| # 2 I was tempted to take a bite of it. | ||
| # 3 But this seemed like a bad idea... | ||
| cyf@MacBookPro individual-shell-tools % cat -n helper-files/helper-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. Same here, what will happen if I try to execute this script as it is written right now? with cyf@MacBookPro etc? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ set -euo pipefail | |
| # 3 It looked delicious. | ||
| # 4 I was tempted to take a bite of it. | ||
| # 5 But this seemed like a bad idea... | ||
| cyf@MacBookPro individual-shell-tools % cat helper-files/* | nl -v 1 -n ln | ||
|
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 I try to execute this script as it is written right now? with cyf@MacBookPro etc? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ set -euo pipefail | |
|
|
||
| # 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 | ||
|
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! It distinguishes Doctor lines from usual lines just having "Doctor" in it |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ set -euo pipefail | |
|
|
||
| # 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 -h '^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. What will happen when we pass -h command line argument? Is it what we want to achieve in this task? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,10 @@ 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. | ||
| # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. | ||
|
|
||
| ls % ls -1t 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. What will happen if I try to execute the script with ls % part? |
||
|
|
||
| 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). | ||
| # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. | ||
| ls -1tr child-directory | ||
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.
How many times this loop is going to be executed? Taking the answer into account, which benefits does the loop grant us here, if any?