Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - General > Member Success Stories
User Name
Password Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.


  Search this Thread
Old 07-19-2010, 07:20 AM   #1
Registered: Apr 2003
Posts: 722

Rep: Reputation: 73
Tools to parse NMEA GPS data : grep & awk

Recently I decided to fire up an old gps unit (Earthmate GPS BT-20) I had laying around and see if I could get it to run with Ubuntu 10.04.

Plug in the unit and give it time to acquire a fix then check dmesg to see what device name it has been given. If desired you can assign the device a permanent location with udev. In my case the unit was located at /dev/ttyUSB4.
carl@wizard:~$ cat /dev/ttyUSB4
These are NMEA sentences. To save to a file open a terminal and run
cat /dev/ttyUSB4> file.txt
Use control-C to stop the process.

cat /dev/ttyUSB4 | grep --line-buffered   GPGGA > earth.txt
will write selected lines, in this case GPGGA to a file.

awk -F, '/\$GPGGA/ {print  strftime("%Y-%m-%d "),  $2, (substr($3,0,2) + (substr($3,3) / 60.0)) $4,  (substr($5,0,3) + (substr($5,4) / 60.0)) $6, $10; fflush();}' /dev/ttyUSB4 > earth1.txt
This command will cut out the info I want: time,lat/long, altitude and add the date.

I got part of the awk string here:

and the rest of it here:

especially the part about line buffered input.

Last edited by mjolnir; 07-19-2010 at 09:05 AM. Reason: Prematurely hit the save button.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get data from multi lined text file using awk, sed or perl - grep & cut not upto par cam34 Programming 4 07-02-2010 03:10 AM
Python script parse NMEA data from GlobalSat BU-353 buffdigger Linux - Newbie 1 04-07-2010 07:29 PM
Reading NMEA from GPS and output it in the USB port OlaJi Linux - Hardware 1 05-21-2009 06:56 AM
sed/awk/grep for multiple line data hotrodmacman Programming 8 10-18-2007 11:06 AM
How do I zip and attach the output data of a grep | awk | mail shell script? 360 Programming 1 05-08-2002 08:26 AM

All times are GMT -5. The time now is 09:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration