Demo on data wrangling using Bash
- The Tragedy of Coriolanus by "Shakespeare"
http://shakespeare.mit.edu/coriolanus/full.html
I have choosen two speakers to retrive the data, they are named as follows :-
- Speaker 1 :- BRUTUS
- Speaker 2 :- CORIOLANUS
- curl command to fetch the data
curl "http://shakespeare.mit.edu/coriolanus/full.html" -O > input.txt
- To count the number of times 'BRUTUS'
grep -i 'BRUTUS' input.txt -c
- To calculate the number of words "CORIOLANUS"
grep -i 'CORIOLANUS' input.txt -c
- Total number of words calculated for both 'BRUTUS' and 'CORIOLANUS'
$ eval "$(paste -d+ <(sed 's/\(.*\)/echo $((\1/' brutusCount.txt) <(sed 's/\(.*\)/\1))/' coriolanusCount.txt))"