Skip to content

Commit ad452eb

Browse files
authored
Update IV Functions and Automation.py
1 parent 7ab1ce2 commit ad452eb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Introduction to Bash Scripting/IV Functions and Automation.py

+22
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,28 @@
112112
repl:~/workspace$ bash script.sh
113113
456 out of 632 as a percent is 72.15%
114114

115+
"""
116+
### Sports analytics function
117+
118+
- Create a function called get_number_wins using the function-word method.
119+
- Create a variable inside the function called win_stats that takes the argument fed into the function to filter the last step of the shell-pipeline presented.
120+
- Call the function using the city Etar.
121+
- Below the function call, try to access the win_stats variable created inside the function in the echo command presented.
122+
"""
123+
# Create a function
124+
function get_number_wins () {
125+
126+
# Filter aggregate results by argument
127+
win_stats=$(cat soccer_scores.csv | cut -d "," -f2 | egrep -v 'Winner'| sort | uniq -c | egrep "$1")
128+
129+
}
130+
131+
# Call the function with specified argument
132+
get_number_wins "Etar"
133+
134+
# Print out the global variable
135+
echo "The aggregated stats are: $win_stats"
136+
115137
"""
116138
### Create a function with a local base variable
117139

0 commit comments

Comments
 (0)