#!/bin/ksh set -e date_display=`date "+%a %d %b %Y"` date_file=`date +%Y-%m-%d` #lynx -dump https://www.agroprombank.com/info/rates.html > rates.txt sed -rn '/^ Текущие коммерческие курсы валют на .*/,/^Мы на связи/p' rates.txt > rates-short.txt sed -rn '/^ Курсы валют «APB Online» на .*/,/^ Курс потребительских кредитов на .*/p' rates.txt > rates-apb.txt echo -n writing $date_file.md ... cat < $date_file.md && echo done echo echo Pridnestrovian ruble \(RUP\) conversion rates as of `date` echo official_usd=`sed -n 46p rates-short.txt` official_eur=`sed -n 47p rates-short.txt` official_mdl=`sed -n 48p rates-short.txt` official_uah=`sed -n 49p rates-short.txt` official_rub=`sed -n 50p rates-short.txt` echo official USD is $official_usd rup echo official EUR is $official_eur rup echo official MDL is $official_mdl rup echo official UAH is $official_uah rup echo official RUB is $official_rub rup echo apb_usd=`grep USD/RUP rates-apb.txt | awk '{print $3}'` apb_eur=`grep EUR/RUP rates-apb.txt | awk '{print $3}'` apb_mdl=`grep MDL/RUP rates-apb.txt | awk '{print $3}'` apb_uah=`grep UAH/RUP rates-apb.txt | awk '{print $3}'` apb_rub=`grep RUB/RUP rates-apb.txt | awk '{print $3}'` apb__usd=`grep USD/RUP rates-apb.txt | awk '{print $4}'` apb__eur=`grep EUR/RUP rates-apb.txt | awk '{print $4}'` apb__mdl=`grep MDL/RUP rates-apb.txt | awk '{print $4}'` apb__uah=`grep UAH/RUP rates-apb.txt | awk '{print $4}'` apb__rub=`grep RUB/RUP rates-apb.txt | awk '{print $4}'` echo APB Online buys USD at $apb_usd and sells at $apb__usd echo APB Online buys EUR at $apb_eur and sells at $apb__eur echo APB Online buys MDL at $apb_mdl and sells at $apb__mdl echo APB Online buys UAH at $apb_uah and sells at $apb__uah echo APB Online buys RUB at $apb_rub and sells at $apb__rub echo float gap_usd (( gap_usd = apb__usd - apb_usd )) typeset -F 2 percent_usd (( percent_usd = gap_usd * 100 / official_usd )) float gap_eur (( gap_eur = apb__eur - apb_eur )) typeset -F 2 percent_eur (( percent_eur = gap_eur * 100 / official_eur )) float gap_mdl (( gap_mdl = apb__mdl - apb_mdl )) typeset -F 2 percent_mdl (( percent_mdl = gap_mdl * 100 / official_mdl )) float gap_uah (( gap_uah = apb__uah - apb_uah )) typeset -F 2 percent_uah (( percent_uah = gap_uah * 100 / official_uah )) float gap_rub (( gap_rub = apb__rub - apb_rub )) typeset -F 2 percent_rub (( percent_rub = gap_rub * 100 / official_rub )) echo USD gap between buy and sell is $gap_usd - that is $percent_usd% echo EUR gap between buy and sell is $gap_eur - that is $percent_eur% echo MDL gap between buy and sell is $gap_mdl - that is $percent_mdl% echo UAH gap between buy and sell is $gap_uah - that is $percent_uah% echo RUB gap between buy and sell is $gap_rub - that is $percent_rub% echo float exch_usd (( exch_usd = official_usd - apb_usd )) typeset -F 2 percent__usd (( percent__usd = exch_usd * 100 / official_usd )) float exch_eur (( exch_eur = official_eur - apb_eur )) typeset -F 2 percent__eur (( percent__eur = exch_eur * 100 / official_eur )) float exch_mdl (( exch_mdl = official_mdl - apb_mdl )) typeset -F 2 percent__mdl (( percent__mdl = exch_mdl * 100 / official_mdl )) float exch_uah (( exch_uah = official_uah - apb_uah )) typeset -F 2 percent__uah (( percent__uah = exch_uah * 100 / official_uah )) float exch_rub (( exch_rub = official_rub - apb_rub )) typeset -F 2 percent__rub (( percent__rub = exch_rub * 100 / official_rub )) fixed_amount=100 typeset -F 2 moar_from_usd (( moar_from_usd = apb_usd * fixed_amount / official_usd )) typeset -F 2 moar_from_eur (( moar_from_eur = apb_eur * fixed_amount / official_eur )) typeset -F 2 moar_from_mdl (( moar_from_mdl = apb_mdl * fixed_amount / official_mdl )) typeset -F 2 moar_from_uah (( moar_from_uah = apb_uah * fixed_amount / official_uah )) typeset -F 2 moar_from_rub (( moar_from_rub = apb_rub * fixed_amount / official_rub )) echo USD/RUB costs $exch_usd rup - that is $percent__usd% - for $fixed_amount rup you get $moar_from_usd rup echo EUR/RUB costs $exch_eur rup - that is $percent__eur% - for $fixed_amount rup you get $moar_from_eur rup echo MDL/RUB costs $exch_mdl rup - that is $percent__mdl% - for $fixed_amount rup you get $moar_from_mdl rup echo UAH/RUB costs $exch_uah rup - that is $percent__uah% - for $fixed_amount rup you get $moar_from_uah rup echo RUB/RUB costs $exch_rub rup - that is $percent__rub% - for $fixed_amount rup you get $moar_from_rub rup echo echo all done