123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. . <(ffoom init)
  3. ffoo import core
  4. uri='https://www.cnb.cz/en/financial_markets/foreign_exchange_market/exchange_rate_fixing/daily.txt'
  5. get_field() {
  6. local wntcur=$1
  7. local wntfld=${2:-Rate}
  8. local fldn
  9. case "$wntfld" in
  10. Country|Currency|Amount|Code|Rate) true;;
  11. *) usage_is "code Country|Currency|Amount|Code|Rate" ;;
  12. esac
  13. local date head
  14. read date
  15. read head
  16. IFS='|'; while read Country Currency Amount Code Rate;
  17. do
  18. test "$wntcur" = "$Code" && echo ${!wntfld}
  19. done
  20. }
  21. curl --insecure --silent "$uri" \
  22. | get_field ${1:-USD} Rate