Sports analytics function
You have been contracted back to the soccer league to help them with some sports analytics. You notice that a number of the scripts undertake aggregations, just like you did in a previous exercise. Since there is a lot of duplication of code, this is an excellent opportunity to create a single useful function that can be called at many places in the script.
Your task is to create a Bash function that will take in a city name and find out how many wins they have had since recording began.
Inside the main function, this script will call out to a shell-within-a-shell which is captured in a (by default, global) variable. You can then access this variable outside the function. This was the first technique discussed in the video for getting data out of a function.
Most of the shell pipeline used has been done for you, though of course feel free to explore and understand what is happening here. Nothing there should be new to you!
This exercise is part of the course
Introduction to Bash Scripting
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
