Created
September 16, 2015 17:17
-
-
Save amitpdev/8a61cf1f4a43973e570b to your computer and use it in GitHub Desktop.
Use this awk script to adjust standard GPX files downloaded from any site (bikes) into a GPX format that is supported by Xcode.
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
awk ' | |
BEGIN { | |
buffer="" | |
} | |
{ | |
gsub(/<\/*trk>/,"",$0) | |
gsub(/<\/*trkseg>/,"",$0) | |
gsub(/<trkpt/,"<wpt", $0) | |
gsub(/<\/trkpt>/,"<\/wpt>", $0) | |
} | |
/<wpt/,/<\/wpt>/ { | |
buffer=buffer $0 | |
if ($0 !~ "<\/wpt>") { | |
buffer=buffer "\n" | |
} | |
} | |
/<\/wpt>/ { | |
#print buffer | |
buffer="" | |
} | |
END { | |
}' $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All the buffer calculation is not needed.
The same effect can be achieved by editing the original file and printing the result (which is what the script is already doing, but by using print is printing twice the same things)