Descargamos los datos de aemet Web con la info: http://www.aemet.es/es/eltiempo/prediccion/municipios/horas/tabla/madrid-id28079\\ tabla por horas: https://www.aemet.es/es/eltiempo/prediccion/municipios/horas/tabla/madrid-id28079 Descargamos en xml: curl --silent -o precipitacion.xml http://www.aemet.es/xml/municipios_h/localidad_h_28079.xml Tiene el siguiente formato para mm de agua: 0 0 0 0 0 0 0 Ip 0 0 Ip 0 0 0 0 0 0 0 0 0 0 0 0 0 Donde pone Ip significa que es inapreciable, lo cambiamos por 0.05 Sumo todos los valores. Para el % de precipitación el formato del xml es éste: 0 25 45 20 10 0 0 0 Cogemos el máximo de los valores, para 48h y para 24h El script quedaría así: #!/bin/bash #Web con la info: http://www.aemet.es/es/eltiempo/prediccion/municipios/horas/tabla/madrid-id28079 #tabla por horas: https://www.aemet.es/es/eltiempo/prediccion/municipios/horas/tabla/madrid-id28079 #Me descargo el xml: curl --silent -o precipitacion.xml http://www.aemet.es/xml/municipios_h/localidad_h_28079.xml let mm24=0 let mm48=0 #Cambio Ip que es inapreciable por 0.05 sed -i 's/Ip/0.05/g' precipitacion.xml while read linea do #Sumo los decimales mm24=$(echo "scale=2; "$mm24"+"$linea| bc -l) #si empieza por cero escribe .1 le añado el cero delante si empieza por punto mm24=${mm24/#./0.} done < <(cat precipitacion.xml | grep /precipitacion | head -24 |awk -F'<|>' {'print $3'}) while read linea do #Sumo los decimales mm48=$(echo "scale=2; "$mm48"+"$linea| bc -l) #si empieza por cero escribe .1 le añado el cero delante si empieza por punto mm48=${mm48/#./0.} done < <(cat precipitacion.xml | grep /precipitacion | tail -24 |awk -F'<|>' {'print $3'}) echo $mm24 > mm24.txt echo $mm48 > mm48.txt grep prob_precipitacion precipitacion.xml|head -4 | awk -F'<|>' {'print $3'}|sort | tail -1 > prob24.txt grep prob_precipitacion precipitacion.xml|tail -4 | awk -F'<|>' {'print $3'}|sort | tail -1 > prob48.txt echo "Probab 24h:"`cat prob24.txt`"%" echo "Lluvia 24h:"$mm24"mm" echo "Probab 48h:"`cat prob48.txt`"%" echo "Lluvia 48h:"$mm48"mm" Una salida de ejemplo sería esta: Probab 24h:45% Lluvia 24h:0.10mm Probab 48h:10% Lluvia 48h:0mm