From 90337273ccb80b753c036923d6de9c90cdee2494 Mon Sep 17 00:00:00 2001 From: Idodo1010 Date: Sun, 9 Feb 2025 17:21:13 +0200 Subject: [PATCH] Add files via upload --- q1.sh | 11 ++++++++++- q2.sh | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 q2.sh diff --git a/q1.sh b/q1.sh index f7ac848..549c0c3 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,10 @@ -This is q1 answer +awk '{print NR}' aliceinwonderland.txt | tail -1 + +awk '{n += gsub(/ Alice /, "")} END {print n}' aliceinwonderland.txt + +awk '{for(i=1;i<=NF;i++) count[$i]++} END {for(word in count) if(count[word] == 1) print word}' aliceinwonderland.txt + + +awk '{for(i=1;i<=NF;i++) count[$i]++} END {for(word in count) print count[word], word}' aliceinwonderland.txt | sort -nr | head -n 5 + +awk '{for(i=1;i<=NF;i++) sum+=length($i); count+=NF} END {print sum/count}' aliceinwonderland.txt diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..242ccda --- /dev/null +++ b/q2.sh @@ -0,0 +1,9 @@ +awk '/Sherlock|Holmes/ {count++} END {print count}' sherlockholmes.txt + +awk '{count += gsub(/Sherlock|Holmes/, "")} END {print count}' sherlockholmes.txt + +awk '{print "Hello:", $0}' sherlockholmes.txt + +awk '{for(i=1;i