Skip to content

IHEB HAMDI | oct2025-2 | Module-Tools | Shell/pipelines - #4

Open
hamdiheb wants to merge 38 commits into
mainfrom
shell/pipelines
Open

IHEB HAMDI | oct2025-2 | Module-Tools | Shell/pipelines#4
hamdiheb wants to merge 38 commits into
mainfrom
shell/pipelines

Conversation

@hamdiheb

@hamdiheb hamdiheb commented Apr 5, 2026

Copy link
Copy Markdown
Owner

In this project, I practiced using core shell commands to process and analyze text files efficiently. Key skills learned:

  • List and explore files using ls
  • Search for patterns and count occurrences with grep
  • Sort data numerically, alphabetically, and by columns using sort
  • Identify duplicates and count them with uniq
  • View the beginning or end of files using head and tail
  • Combine commands with pipelines to perform multi-step data processing in one line

hamdiheb added 30 commits March 22, 2026 15:22

# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
# Your output should contain 6 lines, each with one word and one number on it.
# The first line should be "Ahmed 3".

Copy link
Copy Markdown

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.


grep "" dialogue.txt
# TODO: Write a command to output every line in dialogue.txt said by the Doctor.
# The output should contain 6 lines.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches all lines, no filtering.


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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing case-insensitive flag (-i).

# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing g , only replaces first match per line.

Comment thread jq/script-01.sh
# 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing -r, output includes quotes.

Comment thread jq/script-02.sh

# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing -r, output includes quotes.

Comment thread jq/script-03.sh
# 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing -r, output includes quotes.

Comment thread jq/script-04.sh
# 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing -r, output includes quotes.

Comment thread number-systems/README.md
Convert the decimal number 14 to binary.
Answer:

0001 0100

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect conversion (should be 1110)

Comment thread number-systems/README.md

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing answer

# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t count occurrences (wrong tool/flags)

# 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 No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above

# 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'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect swap logic; transforms incorrectly

@yassineyahya-occ yassineyahya-occ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good overall work, but watch for missing flags and choose the correct tools/filters more carefully.
good job Hamdi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants