Results 1 to 3 of 3

Thread: math and grep

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    math and grep

    Hi all is there a way to use math and grep together?
    Heres the gist:
    There is a long string in a file formatted like this:
    $ stuff,stuff,stuff,stuff,stuff,stuff,A*stuff>

    where stuff is stuff I just dont care about at all, and ,A* is all I want to find in any string that starts with $ and ends with >
    is there some easy way to count the commas (6 of them) then look for the letter "A" Followed by the asterisk, and ending in ">"?
    That seems like the way to go if its possible.
    ~Conradin~

  2. #2
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Re: math and grep

    Code:
     grep '\$GPGLL\,[[:digit:]][[:digit:]][[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]\,[[:alpha:]]\,[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]\,[[:alpha:]]\,[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]][[:digit:]]\,[A]\*' someFile
    matches,
    $GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D>
    which is a valid string, and will deject a string like:
    $GPGLL,4250.5589,S,14718.5004,E,000004.909,V*2D> but will fail, if there is different numbers of numbers.

    Can someone help me simplify this?
    The NEMA Standard Im trying to match is GPGLL listed here:
    http://robosoft.info/en/technologies...ebase/nmea0183
    ~Conradin~

  3. #3
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: math and grep

    Got with help from scu-ba-de-buntu:
    This code validates the nema standard for a GPGll sentence as shown (to my understanding of it) at:
    http://robosoft.info/en/technologies...ebase/nmea0183

    Code:
     grep -E -o '\$GPGLL,[0-9]+\.[0-9]+,[NS],[0-9]+\.[0-9]+,[EW],[0-9]+\.[0-9]+,A\*..>' <filename>
    ~Conradin~

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •