From Event to Action: Accelerate Your Decision Making with Real-Time Automation
2 18-2018-winningest team-total runs
1. 15: How can I use GNU coreutils
& other command line tools to
determine the total number of
runs the winningest team
scored in 2016?
By: Alexander Bitar
2. On your vagrant machine execute the following to
discover the winningest team and store it as a
bash variable (WinTeam):
• WinTeam=$(awk -F, '{if($10>$11) print $4; else if ($11>$10) print $7;}' GL2016.TXT
| awk -F, '{a[$1]++;} END{for (i in a) print i, a[i];}'| sort -nrk2 | head -1 | cut -d' ' -
f1)
3. Execute the following command to ensure
that the variable has stored :
• echo $WinTeam
4. Once we ensure that our Bash Variable is stored,
we can execute the following analysis to retrieve
the total number of runs for the Winningest Team:
• awk –F, -v WinTeam=$WinTeam‘{If($7==WinTeam) print $11; else if
($4==WinTeam) print $10}’ GL2016.TXT | paste –sd+ | bc