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
13 changes: 12 additions & 1 deletion q1.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions q2.sh
Original file line number Diff line number Diff line change
@@ -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