all repos — dotfiles @ d474d5f8e7d6bd7bd443965bedc0cc097aa70b00

linux dotfiles

bin/scripts/calc_investments

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"