all repos — dotfiles @ bc95bc6d4e634f2f8b90e2596184ba3d47e2b5be

linux dotfiles

bin/scripts/calc_investments (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
#!/bin/bash

file="$HOME/docs/org/investments.csv"

sc=$(awk -F, '/,/{gsub(/ /, "",$2); if ($2=="SC") sum+=$1 } END { print sum }' $file)
c=$(awk -F ',' '/,/{gsub(/ /, "",$2); if ($2=="C") sum+=$1 } END { print sum }' $file)
t=$(awk -F ',' '/,/{sum+=$1 } END { print sum }' $file)

echo -e "SC: \t$sc\nC:\t$c\nTotal:\t$t"