Utilizo estos valores para algunos cálculos en aplicaciones. Me permite obtener los valores del día actual.-
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash fecha=`date +"%d-%m-%Y"` uf=`curl -s "https://www.bcentral.cl/inicio" | grep "option value" | grep -e "UF" | cut -d"\"" -f2` dolar=`curl -s "https://www.bcentral.cl/inicio" | grep "option value" | grep -e "LAR" | cut -d"\"" -f2` euro=`curl -s "https://www.bcentral.cl/inicio" | grep "option value" | grep -e "EURO" | cut -d"\"" -f2` utm=`curl -s "https://www.bcentral.cl/inicio" | grep "option value" | grep -e "UTM" | cut -d"\"" -f2` echo "" echo " BANCO CENTRAL DE CHILE $fecha Valores ==> EURO=$euro UTM=$utm DOLAR=$dolar UF=$uf" echo "" exit |
Le doy permisos de ejecución al Script : chmod u+x valores.sh Luego al ejecutarlo obtengo el siguiente resultado : (puedo trabajar con los valores por separado)
1 2 3 |
[desa@monster]$ ./valores_bcentral.sh BANCO CENTRAL DE CHILE 05-08-2025 Valores ==> EURO=1.115,81 UTM=68.647 DOLAR=964,28 UF=39.153,69 |