Skip to content

Instantly share code, notes, and snippets.

@devanjedi
Last active August 29, 2015 14:01
Show Gist options
  • Save devanjedi/338a1130502f9913ada4 to your computer and use it in GitHub Desktop.
Save devanjedi/338a1130502f9913ada4 to your computer and use it in GitHub Desktop.
How to figure out how many matches in a tournament were won by the side batting first (or second)
# How to find out how many matches were won by the side batting first vs. second in IPL 7
1. copy the text in the 'Results' table (here: http://www.espncricinfo.com/indian-premier-league-2014/engine/series/695871.html) to your clipboard (select, Ctrl-C)
2. paste it in a text file (save as say 'ipl7.txt')
3. in Terminal (on OSX, Linux, cygwin), type: 'grep runs <path to ipl7.txt> |wc -l' (without quotes) to get the number of matches won by the side batting first. type 'grep wickets <path to ipl7.txt> |wc -l' (without quotes) to get the number of matches won by the side batting second.
@srushe
Copy link

srushe commented May 22, 2014

This will do it in one command.

grep 'won by' <path to ipl7.txt> | awk '{if ($6 == "runs") { print "first" } else { print "second" } }' | sort | uniq -c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment