diff --git a/q1.sh b/q1.sh index f7ac848..516e077 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,16 @@ -This is q1 answer +#!bin/bash +# +# +awk 'END {print NR}' books/aliceinwonderland.txt + + +awk '/ Alice / {count++} END {print count}' books/aliceinwonderland.txt + + +awk '{ for (i=1; i<=NF; i++) print $i }' books/aliceinwonderland.txt | awk '{a[$1]++} END {for (k in a) print a[k], k}' | awk '$1==1 {print}' + + +awk '{ for (i=1; i<=NF; i++) print $i }' books/aliceinwonderland.txt | awk '{a[$1]++} END {for (k in a) print a[k], k}' | sort -nr | head -5 + + +awk '{ for (i=1;i<=NF;i++) {sum += length($i); count++ }} END {print sum / count}' books/aliceinwonderland.txt diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..445f28a --- /dev/null +++ b/q2.sh @@ -0,0 +1,17 @@ +#!/bin/bash + + +sed -n '/Sherlock\|Holmes/p' books/sherlockholmes.txt | wc -l + + +sed -E 's/(Sherlock|Holmes)/\n\1/g' books/sherlockholmes.txt | grep -E "Sherlock|Holmes" | wc -l + + +sed -E 's/^.{70,}$/long line/' books/sherlockholmes.txt + + +sed -E 's/^[A-Z][a-z]+ [A-Z][a-z]+$/Shelly Orenstein/' books/sherlockholmes.txt + + +sed -E 's/\(([^)]*)\)/[\1]/g' books/sherlockholmes.txt +