Zonsopgang en zonsondergang
Zonsopgang:
curl -s http://zonsondergang.info | grep -o '<span class="vandaag ">.............</span>' | grep -o "..:.. - ..:.." | cut -c 1-5
Zonsondergang:
curl -s http://zonsondergang.info | grep -o '<span class="vandaag ">.............</span>' | grep -o "..:.. - ..:.." | cut -c 9-13
Voorbeeld uitvoering tussen zonsopgang en zonsondergang:
sunrise=$(curl -s http://zonsondergang.info | grep -o '.............' | grep -o "..:.. - ..:.." | cut -c 1-5)
sunset=$(curl -s http://zonsondergang.info | grep -o '.............' | grep -o "..:.. - ..:.." | cut -c 9-13)
begin=$(date --date="$sunrise" +%s)
end=$(date --date="$sunset" +%s)
now=$(date +%s)
if [ "$begin" -le "$now" -a "$now" -le "$end" ]; then
echo Checked daylight.. sun is still up..
echo Doing some meaningful task that can stand daylight..
fi
Laat een antwoord achter