From 1c0343bb72375ad9863ee674400c9adf60ff4020 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 13:43:13 +0000 Subject: [PATCH 01/14] use ls-grep to print 11 files inside sample-files directory --- shell-pipelines/ls-grep/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/ls-grep/script-01.sh b/shell-pipelines/ls-grep/script-01.sh index 8c7d968a2..b77993b26 100755 --- a/shell-pipelines/ls-grep/script-01.sh +++ b/shell-pipelines/ls-grep/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the names of the files in the sample-files directory whose name contains at least one upper case letter. # Your output should contain 11 files. +ls sample-files | grep '[A-Z]' From 60a5314f79943489a942d30b69fb780ec6bc2ea6 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 13:46:36 +0000 Subject: [PATCH 02/14] use ls-grep to output 10 files inside sample-files direcotry which starts with a upper case --- shell-pipelines/ls-grep/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/ls-grep/script-02.sh b/shell-pipelines/ls-grep/script-02.sh index 16f5f71d9..4fa4206cd 100755 --- a/shell-pipelines/ls-grep/script-02.sh +++ b/shell-pipelines/ls-grep/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the names of the files in the sample-files directory whose name starts with an upper case letter. # Your output should contain 10 files. +ls sample-files | grep '^[A-Z]' From 68a1b4948264190cef2f7e753c5a98ad4690dd50 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 13:50:05 +0000 Subject: [PATCH 03/14] ls-grep used to output 7 files inside sample-files which starts with upper case but don't contain any other upper case letter in its name --- shell-pipelines/ls-grep/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/ls-grep/script-03.sh b/shell-pipelines/ls-grep/script-03.sh index a302ab036..2d85418b7 100755 --- a/shell-pipelines/ls-grep/script-03.sh +++ b/shell-pipelines/ls-grep/script-03.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the names of the files in the sample-files directory whose name starts with an upper case letter and doesn't contain any other upper case letters. # Your output should contain 7 files. +ls sample-files | grep '^[A-Z][^A-Z]*$' \ No newline at end of file From b0ea22c1207c31ab003e886eb872ed9d7d13440b Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 13:55:31 +0000 Subject: [PATCH 04/14] use ls-grep-wc in a pipeline to count 7 files inside "sample-files" folder which names start with upper case letter & no more upper case letters for the following letters in the name --- shell-pipelines/ls-grep/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/ls-grep/script-04.sh b/shell-pipelines/ls-grep/script-04.sh index c000b7e3b..f6793becc 100755 --- a/shell-pipelines/ls-grep/script-04.sh +++ b/shell-pipelines/ls-grep/script-04.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to count the number of files in the sample-files directory whose name starts with an upper case letter and doesn't contain any other upper case letters. # Your output should be the number 7. +ls sample-files | grep '^[A-Z][^A-Z]*$' | wc -l \ No newline at end of file From 3c6f364adea10cc67ebe3133d02885be764ae681 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:02:29 +0000 Subject: [PATCH 05/14] sort content inside "scores-table.txt" by person's name, alphabatically --- shell-pipelines/sort-uniq-head-tail/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-01.sh b/shell-pipelines/sort-uniq-head-tail/script-01.sh index 171e1f989..1db218dbb 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-01.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-01.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the scores-table.txt file. # TODO: Write a command to output scores-table.txt, with lines sorted by the person's name. # The first line of your output should be "Ahmed London 1 10 4" (with no quotes). And the third line should be "Chandra Birmingham 12 6". +sort scores-table.txt \ No newline at end of file From 06c916b915f7755eafc1c5ed4744e8dc9a6cc9c5 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:10:21 +0000 Subject: [PATCH 06/14] sort by first score in a descending order --- shell-pipelines/sort-uniq-head-tail/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-02.sh b/shell-pipelines/sort-uniq-head-tail/script-02.sh index 29c3c2524..b65564747 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-02.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-02.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the scores-table.txt file. # TODO: Write a command to output scores-table.txt, with lines sorted by the person's first score, descending. # The first line of your output should be "Basia London 22 9 6" (with no quotes). +sort -k3 -nr scores-table.txt \ No newline at end of file From b219887284e55ceb955c3397a2765bcca0a1750b Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:13:32 +0000 Subject: [PATCH 07/14] use sort-head pipeline to print top 3 players with the highest first score. --- shell-pipelines/sort-uniq-head-tail/script-03.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-03.sh b/shell-pipelines/sort-uniq-head-tail/script-03.sh index bcbaf3420..5efdb3036 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-03.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-03.sh @@ -8,3 +8,4 @@ set -euo pipefail # Basia London 22 9 6 # Piotr Glasgow 15 2 25 11 8 # Chandra Birmingham 12 6 +sort -k3 -nr scores-table.txt | head -n 3 \ No newline at end of file From 978cc0a68e55397e948f865493c929af5e5f35fa Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:17:37 +0000 Subject: [PATCH 08/14] use sort-tail-head pipeline to get the player with the second highest first score. --- shell-pipelines/sort-uniq-head-tail/script-04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-04.sh b/shell-pipelines/sort-uniq-head-tail/script-04.sh index 65a5cfba8..789ca36ce 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-04.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-04.sh @@ -5,3 +5,4 @@ set -euo pipefail # The input for this script is the scores-table.txt file. # TODO: Write a command to output scores-table.txt, with shows the line for the player whose first score was the second highest. # Your output should be: "Piotr Glasgow 15 2 25 11 8" (without quotes). +sort -k3 -nr scores-table.txt | tail -n +2 | head -n 1 \ No newline at end of file From af77931cda2056da0d6dff34307e5178ee437bd7 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:53:38 +0000 Subject: [PATCH 09/14] use sort-uniq pipeline to show all events without duplications --- shell-pipelines/sort-uniq-head-tail/script-05.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-05.sh b/shell-pipelines/sort-uniq-head-tail/script-05.sh index a93cd9f9d..bdc16e1c8 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-05.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-05.sh @@ -6,3 +6,4 @@ set -euo pipefail # TODO: Write a command to show a list of all events that have happened, without duplication. # The order they're displayed doesn't matter, but we never want to see the same event listed twice. # Your output should contain 6 lines. +sort events.txt | uniq \ No newline at end of file From 5eaaf397b77512b33ac4920a3dc7748b4cd34b1d Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 14:58:51 +0000 Subject: [PATCH 10/14] use sort-uniq-c pipleine to show how many times anyone has entered and exited. --- shell-pipelines/sort-uniq-head-tail/script-06.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-06.sh b/shell-pipelines/sort-uniq-head-tail/script-06.sh index 715c7ae5c..930f1d70c 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-06.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-06.sh @@ -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 -c \ No newline at end of file From b78d1c8cfff076f58e627ec397a1c264a0c02868 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 15:28:46 +0000 Subject: [PATCH 11/14] replace all ! with . in the text file --- shell-pipelines/tr/script-01.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/tr/script-01.sh b/shell-pipelines/tr/script-01.sh index 8bb0211e9..3553c5aa5 100755 --- a/shell-pipelines/tr/script-01.sh +++ b/shell-pipelines/tr/script-01.sh @@ -6,3 +6,4 @@ set -euo pipefail # The author got feedback that they're using too many exclamation marks (!). # # TODO: Write a command to output the contents of text.txt with every exclamation mark (!) replaced with a full-stop (.). +tr '!' '.' < text.txt \ No newline at end of file From 71c11c9cb98b5db4f372f26b83ac3776502c02fb Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 15:40:15 +0000 Subject: [PATCH 12/14] swap Ys with Zs & vice versa, while being case insensitive --- shell-pipelines/tr/script-02.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/tr/script-02.sh b/shell-pipelines/tr/script-02.sh index cf3a503a2..4b8395e39 100755 --- a/shell-pipelines/tr/script-02.sh +++ b/shell-pipelines/tr/script-02.sh @@ -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). +tr 'yzYZ' 'zyZY' < text.txt \ No newline at end of file From ce7df62c0b00d12c45f5c93caed72ce8c4d9d440 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 21:47:19 +0000 Subject: [PATCH 13/14] prints all entries and exits --- shell-pipelines/sort-uniq-head-tail/script-06.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell-pipelines/sort-uniq-head-tail/script-06.sh b/shell-pipelines/sort-uniq-head-tail/script-06.sh index 930f1d70c..609c2f858 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-06.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-06.sh @@ -5,4 +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 -c \ No newline at end of file +awk '{print $1}' events.txt | sort | uniq -c \ No newline at end of file From 7369a6a9b960810234a32299e55c0749ca62007e Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 13 Nov 2025 21:52:44 +0000 Subject: [PATCH 14/14] 5 entries and 4 exits --- shell-pipelines/sort-uniq-head-tail/script-07.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell-pipelines/sort-uniq-head-tail/script-07.sh b/shell-pipelines/sort-uniq-head-tail/script-07.sh index 7fd07e1ff..ede279ad4 100755 --- a/shell-pipelines/sort-uniq-head-tail/script-07.sh +++ b/shell-pipelines/sort-uniq-head-tail/script-07.sh @@ -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. +tail -n +2 events-with-timestamps.txt | awk '{print $3}' | sort | uniq -c \ No newline at end of file