all repos — dotfiles @ abcd3c83250383fbcd7ac83cf1b678b7a27cd954

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"