-
Notifications
You must be signed in to change notification settings - Fork 0
IHEB HAMDI | oct2025-2 | Module-Tools | Shell/pipelines #4
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
e7346d7
e691d8e
6ae44ef
ee519ea
9e75471
992998c
dc54f59
899fa3b
90222f4
5032ba4
a4a5fbc
227e155
8e3d8b7
e467605
745f19a
0465ff3
f168750
cda966e
0a823e7
de3f8e3
553e161
cec0f6f
e53d98b
06769c9
d778a23
f95db55
a585500
1bf5ee1
4d9525b
d56a3e0
3a4cb7b
a69e7b3
ebc28b4
88bb3ce
9ef0132
1edd09d
445bb2e
a715e1f
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,5 +2,6 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| grep "" dialogue.txt | ||
| # TODO: Write a command to output every line in dialogue.txt said by the Doctor. | ||
| # The output should contain 6 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. Matches all lines, no filtering. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
|
|
||
| set -euo pipefail | ||
|
|
||
| grep -F "Doctor" dialogue.txt | ||
| # TODO: Write a command to output every line in dialogue.txt that contains the word Doctor (regardless of case). | ||
| # The output should contain 9 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. Missing case-insensitive flag (-i). |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ set -euo pipefail | |
| # TODO: Write a command to output input.txt with all occurrences of the letter `i` replaced with `I`. | ||
| # The output should contain 11 lines. | ||
| # The first line of the output should be: "ThIs Is a sample fIle for experImentIng wIth sed.". | ||
| sed 's/i/I' 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. Missing g , only replaces first match per line. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| [{"name": "Ahmed", "city": "London", "scores": [1, 10, 4]}, {"name": "Basia", "city": "London", "scores": [22, 9, 6]}, {"name": "Mehmet", "city": "Birmingham", "scores": [3, 12, 17]}, {"name": "Leila", "city": "London", "scores": [1]}, {"name": "Piotr", "city": "Glasgow", "scores": [15, 2, 25, 11, 8]}, {"name": "Chandra", "city": "Birmingham", "scores": [12, 6]}] | ||
| [ | ||
| { "name": "Ahmed", "city": "London", "scores": [1, 10, 4] }, | ||
| { "name": "Basia", "city": "London", "scores": [22, 9, 6] }, | ||
| { "name": "Mehmet", "city": "Birmingham", "scores": [3, 12, 17] }, | ||
| { "name": "Leila", "city": "London", "scores": [1] }, | ||
| { "name": "Piotr", "city": "Glasgow", "scores": [15, 2, 25, 11, 8] }, | ||
| { "name": "Chandra", "city": "Birmingham", "scores": [12, 6] } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ set -euo pipefail | |
|
|
||
| # The input for this script is the person.json file. | ||
| # TODO: Write a command to output the name of the person. | ||
| jq '.name' person.json | ||
| # Your output should be exactly the string "Selma", but should not contain any quote characters. | ||
|
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. Missing -r, output includes quotes. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ set -euo pipefail | |
|
|
||
| # The input for this script is the person.json file. | ||
| # TODO: Write a command to output the address of the person, all on one line, with a comma between each line. | ||
| jq -c '.address | join(", ")' person.json | ||
|
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. Missing -r, output includes quotes. |
||
| # Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ set -euo pipefail | |
|
|
||
| # The input for this script is the person.json file. | ||
| # TODO: Write a command to output the name of the person, then a comma, then their profession. | ||
| jq '[.name, .profession] | join(", ")' person.json | ||
| # Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters. | ||
|
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. Missing -r, output includes quotes. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,5 +4,6 @@ set -euo pipefail | |
|
|
||
| # The input for this script is the scores.json file. | ||
| # TODO: Write a command to output just the names of each player, one per line. | ||
| jq '.[].name' scores.json | ||
| # Your output should contain 6 lines, each with just one word on it. | ||
| # Your output should not contain any quote characters. | ||
|
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. Missing -r, output includes quotes. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,60 +6,61 @@ The goal of these exercises is for you to gain an intuition for binary numbers. | |
|
|
||
| Convert the decimal number 14 to binary. | ||
| Answer: | ||
|
|
||
| 0001 0100 | ||
|
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. Incorrect conversion (should be 1110) |
||
| Convert the binary number 101101 to decimal: | ||
| Answer: | ||
|
|
||
| 45 | ||
| Which is larger: 1000 or 0111? | ||
| Answer: | ||
|
|
||
| 1000 | ||
| Which is larger: 00100 or 01011? | ||
| Answer: | ||
|
|
||
| 01011 | ||
| What is 10101 + 01010? | ||
| Answer: | ||
|
|
||
| 11111 | ||
| What is 10001 + 10001? | ||
| Answer: | ||
|
|
||
| 100010 | ||
| What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? | ||
| Answer: | ||
|
|
||
| 15 | ||
| How many bits would you need in order to store the numbers between 0 and 255 inclusive? | ||
| Answer: | ||
|
|
||
| 8 bits | ||
| How many bits would you need in order to store the numbers between 0 and 3 inclusive? | ||
| Answer: | ||
|
|
||
| 2 bits | ||
| How many bits would you need in order to store the numbers between 0 and 1000 inclusive? | ||
| Answer: | ||
|
|
||
| 10 bits | ||
| How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? | ||
| Answer: | ||
|
|
||
| Binary number should have at least 1 bit set to 1 | ||
| Convert the decimal number 14 to hex. | ||
| Answer: | ||
|
|
||
| E | ||
| Convert the decimal number 386 to hex. | ||
| Answer: | ||
|
|
||
| 182 | ||
| Convert the hex number 386 to decimal. | ||
| Answer: | ||
|
|
||
| 902 | ||
| Convert the hex number B to decimal. | ||
| Answer: | ||
|
|
||
| 11 | ||
| If reading the byte 0x21 as a number, what decimal number would it mean? | ||
| Answer: | ||
|
|
||
| 33 | ||
| If reading the byte 0x21 as an ASCII character, what character would it mean? | ||
| Answer: | ||
|
|
||
| ! | ||
| If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? | ||
| Answer: | ||
|
|
||
| dark grey | ||
| If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? | ||
| Answer: | ||
|
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. Missing answer |
||
|
|
||
| If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? | ||
| Answer: | ||
| (170, 0, 255) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ set -euo pipefail | |
| # The input for this script is the events.txt file. | ||
| # TODO: Write a command to show how many times anyone has entered and exited. | ||
| # It should be clear from your script's output that there have been 5 Entry events and 4 Exit events. | ||
| sort events.txt | uniq --group | ||
|
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. Doesn’t count occurrences (wrong tool/flags) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ set -euo pipefail | |
| # TODO: Write a command to show how many times anyone has entered and exited. | ||
| # It should be clear from your script's output that there have been 5 Entry events and 4 Exit events. | ||
| # The word "Event" should not appear in your script's output. | ||
| sort events.txt | uniq --group | ||
|
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 issue as above |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ set -euo pipefail | |
| # so every Y should be a Z, and every Z should be a Y! | ||
| # | ||
| # TODO: Write a command to output the contents of text.txt with every Y and Z swapped (both upper and lower case). | ||
| cat text.txt | tr 'Z' 'z' | tr 'Y' 'y' | tr 'z' 'Z' | tr 'y' 'Y' | ||
|
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. Incorrect swap logic; transforms incorrectly |
||
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.
Works but hardcoded and not flexible.