Average Array

Calculate the arithmetic mean of all numbers in an array.

Code

General
echo "$arr" | tr -d '[]' | tr ',' '\n' | awk '{s+=$1; c++} END {print s/c}'

Parameters

JSON array of numbers

Server

More Bash Snippets