for some time now i really like the bash functions. Consider the one that calculates the average value from the nth column of the file:
avg () { awk -vc="$2" '{n+=$c;m++} END{print n/m,m}' < "$1"; }
Is it possible to rewrite it so that it reads data from the channel? That is, to use the function in the following:
cat data.txt | avg
source share