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(min=="")min=max=$1;
if($1>max)max=$1;
if($1<min )min=$1;
total+=$1;
}
END {
printf "Total: %d, min: %.3f, avg: %.3f, max: %.3f", NR, min, total/NR, max
}
[/pyg]
Can be used like this:
[pyg lang="bash" style="monokai" linenumbers=""]
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

Link to this post!
No comments yet.