-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | 25-SDC-July | Aung Ye Kyaw | sprint 1 | Individual Shell Tool Exercise #113
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
8389417
e0c60c9
c6fc902
fb14f5c
db6c5be
975adea
589a993
d2e0b79
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 |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ set -euo pipefail | |
|
|
||
| # TODO: Write a command to output the contents of all of the files in the helper-files directory to the terminal. | ||
| # 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. | ||
| cd helper-files | ||
| cat helper-1.txt helper-2.txt helper-3.txt | cat -n | ||
|
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 you know how to make cat output and number multiple files in a single command? |
||
| # | ||
| # The output of this command should be something like: | ||
| # 1 Once upon a time... | ||
|
|
||
| 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 -i "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. Can you complete this task only using grep in a single command? |
||
| # 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 every line in dialogue.txt that does not contain the word "Hello" (regardless of case). | ||
| grep -v "Hello" dialouge.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. The task is also asking about case insensitivity here - can you update your solution for that? |
||
| # The output should contain 10 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 name of every `.txt` file in this directory which contains a line of dialogue said by the Doctor. | ||
| grep "^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. Can you build a single grep command that only shows the filename in the output? |
||
| # The output should contain two filenames. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,14 @@ 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. | ||
| cd child-directory | ||
| ls -1t | ||
| # 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). | ||
| cd child-directory | ||
| ls -1t | tail -r | ||
|
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. On my system tail -r does not seem to be a valid command. Can you complete this only using a single ls command? |
||
| # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ | |
| set -euo pipefail | ||
|
|
||
| # TODO: Write a command to output input.txt removing any line which contains a number. | ||
| sed '/^[0-9] [[:space]]/d' input.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. Is it necessary for your regexp to include the [[:space]] test? |
||
| # The output should contain 6 lines. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
|
|
||
| # TODO: Write a command to output input.txt with one change: | ||
| sed 's/^\([0-9][0-9]*\) \(.*\)/\2 \1/' input.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 you need two number groups in your regexp here? |
||
| # If a line starts with a number and a space, make the line instead end with a space and the number. | ||
| # So line 6 which currently reads "37 Alisha" should instead read "Alisha 37". | ||
| # The output should contain 11 lines. | ||
|
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. Hello! Please ensure this PR only contains files for the shell tools exercises. Please create another PR for the number systems exercise. Creating a separate branch for this will make things easier :) |
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.
Will this still work if the player makes more than a few attempts?