summaryrefslogtreecommitdiff
path: root/ledger-price-db-update.sh
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2017-10-21 10:39:34 +0200
committerAnton Bobov <abobov@gmail.com>2017-10-21 10:39:34 +0200
commit1f44d74c080c168ccdb315f18a99f270f09c548d (patch)
tree94be07cc74b594b315fa8cb064a3f9f667070c16 /ledger-price-db-update.sh
parent95e920f6fe2de0b26cd8af072b29438c9a8e83cc (diff)
Update bin.
+ clipboard-stream: prints clipboard changes to stdout * ledger price db refactoring, added new xe
Diffstat (limited to 'ledger-price-db-update.sh')
-rwxr-xr-xledger-price-db-update.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/ledger-price-db-update.sh b/ledger-price-db-update.sh
index 084b27c..478efb9 100755
--- a/ledger-price-db-update.sh
+++ b/ledger-price-db-update.sh
@@ -17,8 +17,18 @@ xe() {
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=p"
}
-usd=$(xe "USDRUB=X")
-eur=$(xe "EURRUB=X")
+print_rate() {
+ currency="$1"
+ symbol="$2"
+
+ val=$(xe "$currency=X")
+
+ test -n "$val" && echo P $(date +"%Y/%m/%d %H:%M:%S") $symbol $val R
+}
+
+{
+ print_rate "USDRUB" "\$"
+ print_rate "EURRUB" "€"
+ print_rate "PLNRUB" "P"
+} >> "$PRICE_DB_FILE"
-test -n "$usd" && echo P $(date +"%Y/%m/%d %H:%M:%S") \$ $usd R >> "$PRICE_DB_FILE"
-test -n "$eur" && echo P $(date +"%Y/%m/%d %H:%M:%S") € $eur R >> "$PRICE_DB_FILE"