Created
April 23, 2014 11:32
-
-
Save georgehrke/11211721 to your computer and use it in GitHub Desktop.
Shellscript to export VTIMEZONE data from lightnings timezones.sqlite
This file contains hidden or 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/zsh | |
num=$(sqlite3 timezones.sqlite "select COUNT(*) from tz_data where component is not null"); | |
for i in {1..$num} | |
do | |
NAME=$(sqlite3 timezones.sqlite "select tzid from tz_data where component is not null limit 1 offset $(($i-1))"); | |
DATA=$(sqlite3 timezones.sqlite "select component from tz_data where component is not null limit 1 offset $(($i-1))"); | |
NAME=$(echo $NAME | tr / - | tr '[:lower:]' '[:upper:]'); | |
NAME="timezones/$NAME.ics"; | |
touch $NAME; | |
echo $DATA > $NAME; | |
done | |
num2=$(sqlite3 timezones.sqlite "select COUNT(*) from tz_data where component is null"); | |
for j in {1..$num2} | |
do | |
NAME=$(sqlite3 timezones.sqlite "select tzid from tz_data where component is null limit 1 offset $(($j-1))"); | |
ALIAS=$(sqlite3 timezones.sqlite "select alias from tz_data where component is null limit 1 offset $(($j-1))"); | |
DATA=$(sqlite3 timezones.sqlite "select component from tz_data where tzid='$ALIAS'"); | |
ESCAPEDNAME=$(echo $NAME | sed -e 's/[]\/()$*.^|[]/\\&/g'); | |
ESCAPEDALIAS=$(echo $ALIAS | sed -e 's/[]\/()$*.^|[]/\\&/g'); | |
DATA=$(echo $DATA | sed -e s/$ESCAPEDALIAS/$ESCAPEDNAME/g); | |
NAME=$(echo $NAME | tr / - | tr '[:lower:]' '[:upper:]'); | |
NAME="timezones/$NAME.ics"; | |
touch $NAME; | |
echo $DATA > $NAME; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment