34 lines
527 B
Bash
34 lines
527 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
today=$(date +%d/%m/%Y)
|
||
|
prev_week=$(date +%d/%m/%Y -d '-7 day')
|
||
|
|
||
|
usd=R01235
|
||
|
|
||
|
cc=($(curl --no-progress-meter "https://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=$prev_week&date_req2=$today&VAL_NM_RQ=$usd" | \
|
||
|
sed -e "s/<[A-Z]/\n\0/g" | \
|
||
|
grep Value | \
|
||
|
sed -e "s#<\/\?\w\+>##g" | \
|
||
|
sed -e "s/,/./g"))
|
||
|
|
||
|
diff=$(echo ${cc[-2]} ${cc[-1]} | awk '{ print $1 - $2 }')
|
||
|
|
||
|
case $1 in
|
||
|
"diff")
|
||
|
echo $diff
|
||
|
;;
|
||
|
|
||
|
"cur")
|
||
|
echo ${cc[-1]}
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo "${cc[-1]} ($diff)"
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit 0
|
||
|
|