Skip to content

Instantly share code, notes, and snippets.

@raresteak
Created February 4, 2021 14:53
Show Gist options
  • Save raresteak/c4606ec98c7daf1a75e86335c7d8ff9d to your computer and use it in GitHub Desktop.
Save raresteak/c4606ec98c7daf1a75e86335c7d8ff9d to your computer and use it in GitHub Desktop.
Returns remaining seconds, minutes, hours from present time to new day.
#!/bin/bash
TOMORROW=$(date -d "tomorrow" +%Y%m%d)
NOW=$(date -d "now" +%s)
EOD=$(date -d "$TOMORROW" +%s)
echo "$(date)"
echo "Remaining seconds today: $(expr $EOD - $NOW)"
echo "Remaining minutes today: $(echo "scale=2;$(expr $EOD - $NOW)/60" | bc)"
echo "Remaining hours today: $(echo "scale=2;($(expr $EOD - $NOW)/60)/60" | bc)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment