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
11 changes: 10 additions & 1 deletion q1.sh
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
This is q1 answer
awk 'END {print NR}' aliceinwonderland.txt

awk '{for (i=2;i<NF;i++) { if ($i=="Alice"){ count ++ }}} END {print count}' aliceinwonderland.txt

awk ' {for (i = 2; i < NF; i++) { print $i } }' aliceinwonderland.txt | sort | uniq -c | awk ' $1 = 1 {print $2}'


cat aliceinwonderland.txt | tr -d '[:punct:]' | tr -s '[:blank:]' ' ' | tr ' ' '\n' | grep '[[:alnum:]]' | sort | uniq -c | sort -nr | head -10

cat aliceinwonderland.txt | tr -d '[:punct:]' | tr -s '[:blank:]' ' ' | tr ' ' '\n' | grep '[[:alnum:]]' | awk ' {sum += length($1); count++} END {print sum/count } '
5 changes: 5 additions & 0 deletions q2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sed -n "/Sherlock\|Holmes/p" sherlockholmes.txt | wc -l
sed "s/Sherlock/\nSherlock/g; s/Holmes/\nHolmes/g" sherlockholmes.txt | sed -n "/Sherlock\|Holmes/p" | wc -l
sed -E "/^.{70}/ s/.*/Long Line/" sherlockholmes.txt # I would have added -i to change the original file
sed -E "s/[A-Z][a-z]+ [A-Z][a-z]+/Amit Pinchas/g" sherlockholmes.txt
sed -E "s/\((.*)\)/\[\1\]/g" sherlockholmes.txt