Advertisement
LightningStalker

combineloc.sh - Merge geocaching waypoint into existing

Oct 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 KB | None | 0 0
  1. #!/bin/sh
  2. ####################
  3. # combineloc.sh by The Lightning Stalker 2008
  4. # 10/21/2017 - Updated for newer versions of `test`
  5. #
  6. # Script to combine GPS .loc files in the current directory into one file
  7. # Works only for xml formatted .loc files 8 lines long.
  8. #
  9. #      j is going to be set for our first iteration in which we print out the
  10. # header.  Subsequent iterations print the data lines stripped from each .loc
  11. # file.  Then the trailing </loc> is printed before EOF.
  12. ####################
  13.  
  14. j=1
  15. for i in *.loc; do
  16.     if test "x$j" != "x" ; then
  17.         echo '<?xml version="1.0" encoding="UTF-8"?>'
  18.         echo '<loc version="1.0" src="Groundspeak">'
  19.         echo
  20.         unset j
  21. #       continue
  22.     fi
  23.     if test `wc -l "$i" | awk '{print $1}'` -eq "8" ; then
  24.         echo '<waypoint>'
  25.         tail -n6 "$i" | head -n5
  26.         echo '</waypoint>'
  27.     fi
  28. done
  29. echo
  30. echo '</loc>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement