From 54aded22b6c10c520224395f46cb520bb200ac63 Mon Sep 17 00:00:00 2001 From: Yotam Ben Moshe Date: Thu, 22 Jan 2026 16:37:18 +0200 Subject: [PATCH] Added my answers (Yotam ben moshe) to q1 and q2 --- q1.sh | 13 ++++++++++++- q2.sh | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 q2.sh diff --git a/q1.sh b/q1.sh index f7ac848..543a724 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,12 @@ -This is q1 answer +#I used the chat in order to learn and sharpen my skills in awk function. +#There was no single prompt here, but rather an in depth learning dialogue. + +awk 'END {print NR}' aliceinwonderland.txt + +awk 'BEGIN {count =0} { for (i = 1; i <=NF; i++) if ($i == "Alice") count++} END {print count}' aliceinwonderland.txt + +awk '{for (i=1; i<=NF; i++) a[$i]++} END {for (k in a) if (a[k] == 1) print k}' aliceinwonderland.txt + +awk '{for (i=1; i<=NF; i++) a[$i]++} END {for (k in a) print k,a[k]}' aliceinwonderland.txt | sort -k2 -n | tail -5 + +awk 'BEGIN {count = 0; number = 0} {for (i=1; i<=NF; i++) {count = count + length($i); number++}} END {print count/number}' aliceinwonderland.txt diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..e8249c8 --- /dev/null +++ b/q2.sh @@ -0,0 +1,13 @@ +#I used the chat in order to learn and sharpen my skills in writing regular expressions and using the SED function. +#There was no single prompt here, but rather an in depth learning dialogue. + + +sed -E -n '/(Sherlock|Holmes)/=' sherlockholmes.txt | wc -l + +sed -E -n 's/(Sherlock)|(Holmes)/\n\1\2/gp' sherlockholmes.txt | wc -l + +sed -E 's/^.{70,}$/Long line/' sherlockholmes.txt + +sed -E 's/[A-Z][a-z]{2,}\s+[A-Z][a-z]{2,}/Yotam Ben Moshe/g' sherlockholmes.txt + +sed -E 's/\(/\[/g; s/\)/\]/g' sherlockholmes.txt