Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion q1.sh
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
This is q1 answer
awk '{print NR}' aliceinwonderland.txt | tail -1
#3325
awk '{count += gsub(/ Alice /, "")} END {print count+0}' aliceinwonderland.txt
#155
awk '{gsub(/^[[:punct:]]|[[:punct:]]$/, ""); a[$0]++} END{for (w in a) print w,a[w]}' RS='[[:space:]]' aliceinwonderland.txt | awk '$2==1 {print $1}'
awk '{gsub(/[[:punct:]]/, "")} 1' RS='[[:space:]]' aliceinwonderland.txt | sort | uniq -c | sort | tail -6 | head -5
# 498 she
# 610 a
# 717 to
# 774 and
# 1514 the
awk '{gsub(/[[:punct:]]/, "")} 1' RS='[[:space:]]' aliceinwonderland.txt | awk '/./' | awk '{sum += length($0)} END {print sum / NR}'
#4.08109
7 changes: 7 additions & 0 deletions q2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sed -n '/\(Sherlock\|Holmes\)/p' sherlockholmes.txt | wc -l
#463
grep -o '\b\(Sherlock\|Holmes\)\b' sherlockholmes.txt | sed -n '$='
#554
sed -i -e 's/^/Hello:/' sherlockholmes.txt
sed -r 's/([A-Z][a-z]{2,}) ([A-Z][a-z]{2,})/Tamar Katzir/g' sherlockholmes.txt
sed -rn -i 's/\(([^)]*)\)/[\1]/gp; t; p' sherlockholmes.txt