diff --git a/q1.sh b/q1.sh index f7ac848..677ba85 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,15 @@ -This is q1 answer + +#a +awk '{print NR}' aliceinwonderland.txt | wc -l + +#b +grep -o " Alice " aliceinwonderland.txt | wc -l + +#c +grep -Eo " [a-z|A-Z]+ " aliceinwonderland.txt | sort | uniq -c | sort -nr | awk '$1 == 1' + +#d +grep -Eo " [a-z|A-Z]+ " aliceinwonderland.txt | sort | uniq -c | sort -nr | head -n 5 + +#e +grep -Eo [[:alpha:]]+ aliceinwonderland.txt | awk '{sum+=length($0) } END{print sum/NR}' diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..61d88e9 --- /dev/null +++ b/q2.sh @@ -0,0 +1,15 @@ + +#a +sed -E -n '/Sherlock|Holmes/p' sherlockholmes.txt | wc -l + +#b +sed -E -n '/Holmes|Sherlock/p' sherlockholmes.txt | grep -Eo 'Sherlock|Holmes' | wc -l + +#c +awk '{ if (length($0) > 70) print "Long Line"; else print $0 }' sherlockholmes.txt + +#d +sed -E 's/([A-Z])([a-z])+(\s)([A-Z])([a-z])+/Amir/g' sherlockholmes.txt + +#e +sed 's/(/[/g; s/)/]/g' sherlockholmes.txt