Skip to content

Instantly share code, notes, and snippets.

@tjirab
Last active Nov 1, 2018
Embed
What would you like to do?
Shell Tool(s)
#!/bin/sh
#
# World Clock
#
# Set up: place .sh in a folder; add alias to rc file;
# e.g. alias wt='~/sh/world_clock.sh'
#
# Access available time zones in /usr/share/zoneinfo
# To add a time zone, simply add to TIME_ZONES. For
# time zones directly in root folder, add with .,
# e.g. "./CET".
TIME_ZONES="Europe/Amsterdam America/Los_Angeles Europe/Dublin"
OUTPUT=""
for loc in $TIME_ZONES; do
CITY=`echo $loc | sed 's/\// /g' | awk '{ print $2 }'`
CUR_TIME=`TZ=${loc} date | awk '{ print $2 " " $3 " " $5 }'`
TEMP=`awk -v l="$CITY" -v t="$CUR_TIME" 'BEGIN { print l "\t" t }'`
OUTPUT="${OUTPUT}\n${TEMP}"
done
echo $OUTPUT | column -t | sort -k 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment