-
-
Notifications
You must be signed in to change notification settings - Fork 27
London | DONARA BLANC | Module Tools | SPRINT 1 | Individual-Shell-Tools #27
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
359d783
4cc02d0
dff5a9e
290aac5
42c8f5c
c531f85
7676f78
c8c9c4a
10e5c1d
91e1f2a
0e2e1f8
a2447f2
c94f227
5d9f79e
9421db1
d653d64
d4199c9
cb36d54
3194ddb
50b4d23
55bc0ea
feadae8
3e7dec9
66fcffa
ab638fc
862c2b5
a1e2f05
f9b46d0
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,8 @@ 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 '/London/ { if (NF<5) print $1, $NF; else print $1, $5}' 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. praise: Good use of conditional logic in the awk command here! |
||
Ahmed 4 | ||
Basia 6 | ||
Leila 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ 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... | ||
|
||
cat ../helper-files/helper-3.txt | nl # ordered by numbers | ||
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. question: This is good and works, but I'm curious if we can do it without the pipe? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,8 @@ 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... | ||
|
||
# i didn't get this phrase "we want line numbers not to reset at the start of each file." | ||
# so there are two ways to do it | ||
cat -n ../helper-files/*txt # -n number the blank lines and filled out 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. suggestion: It's good to see your working and that you found multiple solutions here, but it would be a good idea to comment one of them out so that your script only outputs once |
||
cat ../helper-files/*.txt | nl # skips the blank lines and comes only filled out lines |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,12 @@ 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 # i tried to use the "" quotes but my terminal didnt accept that | ||
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. question: Why does the terminal not accept those characters? |
||
|
||
Doctor: Hello | ||
Doctor: What's wrong today? | ||
Doctor: That sounds frustrating. When did this start? | ||
Doctor: Say "Hi". | ||
Doctor: You didn't say hello | ||
Doctor: You're welcome, goodbye |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,16 @@ set -euo pipefail | |
|
||
# 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 ^Doctor -c *.txt # this command gaves the expected output | ||
|
||
dialogue.txt:6 | ||
dialogue-2.txt:2 | ||
dialogue-3.txt:0 | ||
|
||
grep ^ Doctor -c *.txt # however here i put a space between the carrot and the search name and it gave me a different output, and i dont know why | ||
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. question: How could we find out what went wrong with that command? |
||
|
||
grep: Doctor: No such file or directory | ||
dialogue.txt:15 | ||
dialogue-2.txt:4 | ||
dialogue-3.txt:3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,17 @@ set -euo pipefail | |
# TODO: Write a command to output input.txt with numbers removed. | ||
# The output should contain 11 lines. | ||
# Line 6 of the output should be " Alisha". | ||
|
||
sed 's/[0-9]*//g' input.txt # however Alisha is not on the 6 line | ||
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. question: Are you sure that she's not on the 6th line? |
||
|
||
This is a sample file for experimenting with sed. | ||
|
||
It contains many lines, and there are some things you may want to do with each of them. | ||
|
||
We'll include some score information: | ||
Alisha | ||
Jacob | ||
Pietro | ||
Katya | ||
|
||
We also should remember, when we go shopping, to get items: oranges,cheese,bread,olives. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,11 @@ set -euo pipefail | |
|
||
# TODO: Write a command to output input.txt removing any line which contains a number. | ||
# The output should contain 6 lines. | ||
|
||
sed -e '/[0-9]/d' input.txt # my output is only 4 lines instead of 6 | ||
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. question: Are you sure? What could we pipe this command into to see how many lines there are programmatically? |
||
|
||
This is a sample file for experimenting with sed. | ||
|
||
It contains many lines, and there are some things you may want to do with each of them. | ||
|
||
We'll include some score information: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ set -euo pipefail | |
# 1 7 39 ../helper-files/helper-2.txt | ||
# 3 19 92 ../helper-files/helper-3.txt | ||
# 5 30 151 total | ||
wc ../helper-files/*.txt # the same as with cat the star * | ||
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. praise: This is a great use of the wildcard, and you'll likely find lots of other useful places to use it as well. |
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.
issue: While it's great to see your output here, please make sure you comment it out. This script is now not executable, it will look for commands that match each of the given names and error out.