#!/bin/bash PROGNAME=${0##*/} set -e # Other globals # Includes . $(miniade) || { echo "${0#*/}: ERROR: miniade failed (hint: run 'miniade' to see error)" >&2; exit 1; } main() { # Process options process_standard_options --special-opts-handler=special_opts_handler MY_ARGS "$@" && set -- "${MY_ARGS[@]}" # Process arguments [ $# = 1 ] || usage GPX_FILE=$1 # Sanity checks and derivations [[ $GPX_FILE =~ \.gpx$ ]] || error "not a GPX file?" CSV_FILE=/tmp/$(basename $GPX_FILE .gpx).csv # Guts info "converting merged GPX to CSV ..." gpsbabel -i gpx -f $GPX_FILE -o unicsv -F $CSV_FILE DB_FILE=/tmp/$PROGNAME.$$.sqlite info "loading into sqlite (database is $DB_FILE) ..." rm -f $DB_FILE sqlite3 $DB_FILE < ] " >&2 exit 1 } main "$@"