<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: quick SED and AKW questions in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020188#M65349</link>
    <description>Personally, I'd use perl:&lt;BR /&gt;&lt;BR /&gt;perl -n -e '/^(.*)RMK/ and { print $1. "\n" }' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;That's the first one.&lt;BR /&gt;&lt;BR /&gt;The third, something like:&lt;BR /&gt;&lt;BR /&gt;perl -n -e '/^(\w+) \d{2}(\d{2})(\d{2}). (\d{3})\d+\w+ .*([MP])(\d+)\/([MP])(\d+) \w(\d+) RMK/ and printf("%s %d:%d %s %s%02d %s%02d %0.2f\n", $1, $2, $3, $4, ($5 == "M" ? "-" : "+"), $6, ($7 == "M" ? "-" : "+"), $8, $9 / 100)'&lt;BR /&gt;&lt;BR /&gt;It's mostly just pattern matching, and manipulation.  Pretty simple stuff.&lt;BR /&gt;&lt;BR /&gt;I'm sure you can work backwards to get the second.&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;</description>
    <pubDate>Fri, 22 Dec 2006 15:13:19 GMT</pubDate>
    <dc:creator>Stuart Browne</dc:creator>
    <dc:date>2006-12-22T15:13:19Z</dc:date>
    <item>
      <title>quick SED and AKW questions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020187#M65348</link>
      <description>I am working with a string that looks like this:&lt;BR /&gt;&lt;BR /&gt;KAPA 221753Z 16010KT 10SM FEW140 SCT200 M01/M11 A2997 RMK AO2 SLP183 4/018 T10061106 10006 21089 51014&lt;BR /&gt;&lt;BR /&gt;I would like to manipulate this file a bit:&lt;BR /&gt;&lt;BR /&gt;1) I want to delete "RMK" and everything after that to the right.&lt;BR /&gt;&lt;BR /&gt;2) I would like to create a 5 column file out of the remaining objects.  Unfortunately, of the remaining data, only the 1st 3 columns (station ID, day of month and time, and wind direction and speed) in the original line are ALWAYS in that sequence.  The last 2 colums (temperature and dewpoint, and altimiter setting) are always before RMK in that order.  However, the stuff between the wind speed and the temperature is variable in length, format, and number of columns.  What I would like the line to look like is this:&lt;BR /&gt;&lt;BR /&gt;KAPA 221753Z 16010KT M01/M11 A2997&lt;BR /&gt;&lt;BR /&gt;3) I'd like to further modify things so that it looks like this:&lt;BR /&gt;&lt;BR /&gt;KAPA 22 17:53 160 10 -01 -11 29.97&lt;BR /&gt;&lt;BR /&gt;(for the temp and dewpoint, M in the original file is -, and P in the original file is +).&lt;BR /&gt;&lt;BR /&gt;BTW, this isn't homework for me -- it is more of an extracurricular research project for me, mixing two of my 3 main loves (computers and weather).  I just haven't mastered sed and awk quite well enough to do the job.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Alan Sheets&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Dec 2006 14:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020187#M65348</guid>
      <dc:creator>Alan_152</dc:creator>
      <dc:date>2006-12-22T14:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: quick SED and AKW questions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020188#M65349</link>
      <description>Personally, I'd use perl:&lt;BR /&gt;&lt;BR /&gt;perl -n -e '/^(.*)RMK/ and { print $1. "\n" }' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;That's the first one.&lt;BR /&gt;&lt;BR /&gt;The third, something like:&lt;BR /&gt;&lt;BR /&gt;perl -n -e '/^(\w+) \d{2}(\d{2})(\d{2}). (\d{3})\d+\w+ .*([MP])(\d+)\/([MP])(\d+) \w(\d+) RMK/ and printf("%s %d:%d %s %s%02d %s%02d %0.2f\n", $1, $2, $3, $4, ($5 == "M" ? "-" : "+"), $6, ($7 == "M" ? "-" : "+"), $8, $9 / 100)'&lt;BR /&gt;&lt;BR /&gt;It's mostly just pattern matching, and manipulation.  Pretty simple stuff.&lt;BR /&gt;&lt;BR /&gt;I'm sure you can work backwards to get the second.&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 22 Dec 2006 15:13:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020188#M65349</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2006-12-22T15:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: quick SED and AKW questions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020189#M65350</link>
      <description>&lt;!--!*#--&gt;Hi Alan:&lt;BR /&gt;&lt;BR /&gt;This seems to fit your requirements (using Perl):&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $line;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    ( $line = $_ ) =~ s/(.+)RMK.+/$1/;&lt;BR /&gt;    my @fields = split /\s+/, $line;&lt;BR /&gt;    next unless $#fields &amp;gt;= 5;&lt;BR /&gt;    my ( $staid, $montm, $winds, $tmpdp, $altm )&lt;BR /&gt;        = ( $fields[0], $fields[1], $fields[2], $fields[-2], $fields[-1] );&lt;BR /&gt;    printf "%s %2s %2s:%2s %3s %2s %s%2s %s%2s %2s.%2s\n", $staid,&lt;BR /&gt;        substr( $montm, 0, 2 ), substr( $montm, 2, 2 ),&lt;BR /&gt;        substr( $montm, 4, 2 ), substr( $winds, 0, 3 ),&lt;BR /&gt;        substr( $winds, 3, 2 ), substr( $tmpdp, 0, 1 ) eq "M" ? "-" : "+",&lt;BR /&gt;        substr( $tmpdp, 1, 2 ), substr( $tmpdp, 4, 1 ) eq "M" ? "-" : "+",&lt;BR /&gt;        substr( $tmpdp, 5, 2 ), substr( $altm,  1, 2 ), substr( $altm, 3, 2 );&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./filter filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 22 Dec 2006 17:18:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020189#M65350</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-22T17:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: quick SED and AKW questions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020190#M65351</link>
      <description>The last perl script was just what I need.  The results are at &lt;A href="http://www.appsremote.com/metar" target="_blank"&gt;www.appsremote.com/metar&lt;/A&gt; .  Thanks!</description>
      <pubDate>Mon, 08 Jan 2007 18:26:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quick-sed-and-akw-questions/m-p/5020190#M65351</guid>
      <dc:creator>Alan_152</dc:creator>
      <dc:date>2007-01-08T18:26:18Z</dc:date>
    </item>
  </channel>
</rss>

