Created
October 2, 2019 11:07
-
-
Save valmat/20d91e575a3c908b352aeb4084a4d45a to your computer and use it in GitHub Desktop.
Get all time zones and their offsets in Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for tz in $(timedatectl list-timezones | grep -v 'UTC') | |
do | |
gmtoff=$(zdump -v "$tz" | grep 'gmtoff' | tail -n1 | grep -oE "[^ ]+$") | |
tz_offset="${gmtoff:7}" | |
if [[ "${gmtoff:0:7}" == "gmtoff=" ]]; then | |
echo "$tz;$tz_offset" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment