annotate bin/budget.sh @ 528:b8857facac02

python/setup_repo.py
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 24 Sep 2013 13:16:23 -0700
parents 25e92f9cf011
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
492
25e92f9cf011 bin/budget.sh
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/bin/bash
25e92f9cf011 bin/budget.sh
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
25e92f9cf011 bin/budget.sh
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 # from http://c2.com/doc/expense/
25e92f9cf011 bin/budget.sh
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
25e92f9cf011 bin/budget.sh
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 exec awk ' $1 ~ /^[A-Z]+[A-Z0-9]*$/ { if (sums[$1] == "" || $1 == "SUM") { sums[$1] = sum # Define Symbol $1 = sum sum = 0 } else { $1 = sums[$1] # Dereference Symbol } } ($1+0) != 0 {$1 = sprintf("%7.2f", $1)} # Pretty Print {print} $2 == "*" {$1 *= $3} # Explicit Calculations $2 == "/" {$1 /= $3} $2 == "DB" {$1 = -$1} $2 == "CR" {$1 = -$1} NF == 0 {sum = 0} # Implicit Summation {sum += $1} ' $1