dotfiles/.local/bin/custom/rateUSD
ziro 202be91f2a ----- Changes: rateUSD
+ Added missing '%' in rateUSD
2020-05-21 15:58:35 +07:00

9 lines
600 B
Bash
Executable file

#!/bin/sh
# get rate value from cnbcindonesia.com
[ ! "$(stat -c %y ~/.cache/rateUSD.txt 2> /dev/null | cut -d' ' -f1)" = "$(date +"%Y-%m-%d")" ] && curl -s "https://www.cnbcindonesia.com/market-data/currencies/IDR=/USD-IDR" | grep -A1 'class="mark_val"' | cut -d'"' -f2 | cut -d'<' -f2 | cut -d'>' -f2 > ~/.cache/rateUSD.txt
enUS='Rate'
idID='Kurs'
lang=$idID
# display rateUSD.txt while replace mark_val with Kurs USD -> IDR:
[ -z $1 ] && sed "s/mark_val/$lang USD -> IDR:/;2 s/^/Rp./" ~/.cache/rateUSD.txt && echo "Sumber: CNBC Indonesia" || grep -A1 "mark" ~/.cache/rateUSD.txt | grep -v "mark"