From 410f624abea6a91149286e85200682488e292281 Mon Sep 17 00:00:00 2001 From: Achiad Avigdori Date: Sat, 24 Jan 2026 19:48:53 +0000 Subject: [PATCH 1/2] Q1 updated with answers to all five sections --- q1.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/q1.sh b/q1.sh index f7ac848..463a5df 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,13 @@ -This is q1 answer +#!/bin/bash + +awk 'END {print NR}' aliceinwonderland.txt + +awk '{for (i=1; i<=NF; i++) if ($i=="Alice") c++} END {print c}' aliceinwonderland.txt #I assumed that the qustion asked for each Alice even if it is in the end/beginning of the row else I would have used (i=2; i<=NF-1; i++) + +sed -E 's/\s+/\n/g' aliceinwonderland.txt | awk 'NF {a[$1]++} END {for (k in a) print a[k], k}' | awk '$1==1 {print $2}' + +sed -E 's/\s+/\n/g' aliceinwonderland.txt | awk 'NF {a[$1]++} END {for (k in a) print a[k], k}' | sort -rn | head -n 5 | awk '{print $2}' + +awk '{for(i=1;i<=NF;i++) sum+=length($i); word+=NF} END{print sum/word}' aliceinwonderland.txt #used GPT for the loop in awk + + From c94daf066d3a45b562a25a0c04c69eeac4d9823d Mon Sep 17 00:00:00 2001 From: Achiad Avigdori Date: Sat, 24 Jan 2026 19:49:39 +0000 Subject: [PATCH 2/2] Q2 updated with answers to all five sections --- q2.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 q2.sh diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..338aa1d --- /dev/null +++ b/q2.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sed -n '/Sherlock\|Holmes/p' sherlockholmes.txt | wc -l # used GPT for "-n" + +sed 's/[[:punct:]]//g' sherlockholmes.txt | sed -E 's/\s+/\n/g' | awk 'NF {if ($0 == "Sherlock" || $0 == "Holmes") count++} END {print count}' + +sed -E 's/^.{70}.*$/Long line./' sherlockholmes.txt + +sed -E 's/[[:upper:]][[:alpha:]]+\s[[:upper:]][[:alpha:]]+/Achiad Avigdori/g' sherlockholmes.txt + +sed 's/(/[/g' sherlockholmes.txt | sed 's/)/]/g'