all repos — dotfiles @ d892bfcf6741133441a7b07391d6ee5c330acc4a

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"