Awk
From Attie's Wiki
This page contains some example awk scripts.
8-bit ADC battery voltage reading
Contents of minicom.cap
:
160 159 159 159 158 158 158 158 157 156 157 156 156 156 155 155 155 155 154 154 154 154 154
Command:
cat minicom.cap | sort -r | uniq -c | \ awk 'BEGIN{tot=0; printf "hh:mm\tvoltage\n"} {tot += $1; printf "%2d:%02d\t%.2fv\n", ($1/60), ($1%60), (((3.3 / 256) * $2) * 2)} END{printf "Total: %d:%02d\n", (tot/60), (tot%60)}'
Output:
hh:mm voltage 0:01 4.12v 0:03 4.10v 0:04 4.07v 0:02 4.05v 0:04 4.02v 0:04 4.00v 0:05 3.97v Total: 0:24