diff --git a/q1.sh b/q1.sh index f7ac848..bd1c8e2 100644 --- a/q1.sh +++ b/q1.sh @@ -1 +1,10 @@ -This is q1 answer +#a +awk '{print NR}' aliceinwonderland.txt | tail -1 +#b +grep -o " Alice " aliceinwonderland.txt | wc -l +#c +grep -E -o "[A-Za-z]+" aliceinwonderland.txt | sort | uniq -c | sort -h | awk '$1 == 1' +#d +grep -E -o " [A-Za-z]+ " aliceinwonderland.txt | sort | uniq -c | sort -rh | head -n 5 +#e +grep -E -o "[A-Za-z]+" aliceinwonderland.txt | awk '{total+=length($0)} END{print total/NR}' diff --git a/q2.sh b/q2.sh new file mode 100644 index 0000000..d1ea2b9 --- /dev/null +++ b/q2.sh @@ -0,0 +1,10 @@ +#a +sed -E -n '/Sherlock|Holmes/p' sherlockholmes.txt | wc -l +#b +sed -E -n '/Sherlock|Holmes/p' sherlockholmes.txt | grep -o -E 'Sherlock|Holmes' | wc -l +#c +awk '{if (length($0)>70) print "Long line"; else print $0}' sherlockholmes.txt +#d +sed -E 's/([[:upper:]]){1}([a-z])+(\s)([[:upper:]]){1}([a-z])+/Maya/g' sherlockholmes.txt +#e +sed 's/(/[/g; s/)/]/g' sherlockholmes.txt