You want to transform an XML document, so you should use XML tools ... xmlstarlet is probably the best command-line based tool for this sort of job. http://xmlstar.sf.net/
Replace the contents of the <name> field. This is really the /gpx/wpt/name field ... Replace the contents of the <cmt> field. This is really the /gpx/wpt/cmt field ... (Sidenote -- don't use 2 digit years unless you have broken software somewhere. Use 4 digit years) NEWDATE=$(date +%H%M) NEWCMT=$(date +%Y%m%d%H%M) xmlstarlet ed -N G="http://www.topografix.com/GPX/1/0" -u ///G:name -v WPT"$NEWNAME" -u ///G:cmt -v "$NEWCMT" <?xml version="1.0" encoding="UTF-8"?> <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> <time>2008-08-06T23:57:56Z</time> <bounds minlat="-43.571090000" minlon="172.689703333" maxlat="-43.571090000" maxlon="172.689703333"/> <wpt lat="-43.571090000" lon="172.689703333"> <ele>-2.800000</ele> <time>2008-08-06T23:57:50Z</time> <name>WPT1234</name> <cmt>200808081622</cmt> <desc>WPT001</desc> <fix>dgps</fix> <sat>9</sat> <hdop>0.930000</hdop> <vdop>1.380000</vdop> <pdop>1.660000</pdop> </wpt> </gpx> -jim
