Minimum, maximum, average and more – Useful little shell scripts

Just a collection of a bit of sh/bash/awk/zsh scripts to make your life in the shell easier 🙂

Over time I might add some more, but in the mean time don’t forget to checkout my Github Gists where a few of these are: Wolph’s gists

Also, my dotfiles collection could be useful here 🙂

Little script to do min/max/avg/total count for some given shell input:

#!/usr/bin/env awk -f
# "minmaxavg" shell script to calculate the minimum, maximum, average and count with awk
    if($1<min )min=$1;
    printf "Total: %d, min: %.3f, avg: %.3f, max: %.3f", NR, min, total/NR, max

Can be used like this:
&#91;pyg lang="bash" style="monokai" linenumbers=""&#93;
cat some_file_with_lots_of_numbers | minmaxavg

# Or something useful, timing my shell to optimize my .zshrc
for i in $(seq 5); do time zsh -i -c exit > /dev/null; done 2>&1 | awk '{print $13}' | minmaxavg

Bookmark and Share


About Rick van Hattem

Rick van Hattem is a Dutch Internet entrepreneur and co-founder of
No comments yet.

Leave a Reply