7
0
mirror of https://github.com/marado/RNID.git synced 2024-12-22 11:55:59 +00:00
rnid/scripts/51-dgeg.sh

18 lines
759 B
Bash
Raw Normal View History

#!/bin/bash
wget https://www.dgeg.gov.pt/pt/estatistica/energia/petroleo-e-derivados/vendas-mensais/ -o /dev/null -O - | \
hxnormalize -x -l 1000 | hxselect div .tema-content > dgeg
if [ ! "$(diff dgeg scripts/51/dgeg|wc -l)" -eq "0" ]; then
echo "dgeg: incumprimento pode já não existir";
else
echo "dgeg: Incumprimento mantém-se, a actualizar o README (faça um git diff, valide, e commit!)";
while IFS='' read -r line || [[ -n "$line" ]]; do
test "$(echo "$line"|grep -v -c "dgeg")" -eq "1" \
&& echo "$line" \
2024-10-18 19:31:33 +00:00
|| (h=$(echo "$line"|cut -d\| -f1-4); t=$(echo "$line"|cut -d\| -f6-); nc=$(echo "$line"|cut -d\| -f5 | wc -m); printf "%s| %-$((nc-2))s|%s\n" "$h" "$(date +%Y/%m/%d)" "$t");
done < README.md > new
mv new README.md
fi
rm dgeg