Skip to content

Instantly share code, notes, and snippets.

@yradunchev
Created June 17, 2018 18:27
Show Gist options
  • Save yradunchev/f0ac28694d3fe791ee6640e7383ba1e2 to your computer and use it in GitHub Desktop.
Save yradunchev/f0ac28694d3fe791ee6640e7383ba1e2 to your computer and use it in GitHub Desktop.
download xr from DSK Bank to ledger-cli prices.db file
xrupdate () {
curl -s 'https://dskbank.bg/restapi/dsk/GetCurrencyRates?format=json' |
sed -e 's/[{}]/\n/g' -e 's/"//g' | sed -e '2~2d' |
awk -v date="$(date +"%Y-%m-%d")" -F[,:] 'NF && $4!=0{print "P " date" 00:00:00 "$6" "$4 " BGN"}' >> ~/L/ledger/data/prices.db
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment