<?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: F$EXTRACT Help in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056826#M84979</link>
    <description>&lt;!--!*#--&gt;It seems to me you fail to recognize that F$ELEMENT does not recognize natural words, but simply counts every single seperator.&lt;BR /&gt;&lt;BR /&gt;I suspect that the line "jul 2" actually has an extra space, although that is not visible in this forum output.&lt;BR /&gt;If you want to pick up the 6'th word then you first have to compress mulltiple whitespace characters into 1.&lt;BR /&gt;&lt;BR /&gt;Probably something like:&lt;BR /&gt;$ log_compressed = F$EDIT(LOG,"COMPRESS")&lt;BR /&gt;$ EXACT_TIME = F$ELEMENT(6," ", log_compressed)&lt;BR /&gt;&lt;BR /&gt;Other example:&lt;BR /&gt;$ write sys$output f$ele(1," ","a b c")&lt;BR /&gt;b&lt;BR /&gt;$ write sys$output f$ele(1," ","a  b c")&lt;BR /&gt;&lt;BR /&gt;$ write sys$output f$ele(1," ",f$edit("a  b c","compress"))&lt;BR /&gt;b&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What problem are you really trying to solve?&lt;BR /&gt;I find that parsnig log file is MUCH easier in PERL or AWK once you get going a little bit with those tools.&lt;BR /&gt;&lt;BR /&gt;In this case for example:&lt;BR /&gt;&lt;BR /&gt;$ perl -lne "print $1 if /(\d+):\d\d:\d\d/" tmp.txt&lt;BR /&gt;11&lt;BR /&gt;06&lt;BR /&gt;&lt;BR /&gt;The "REGULAR EXPRESSION" /(\d+):\d\d:\d\d/ give something to match on.&lt;BR /&gt;/ = start RE&lt;BR /&gt;( = start remembering in variable $1&lt;BR /&gt;\d+ = one or more of decimals (hours)&lt;BR /&gt;) = stop remembering&lt;BR /&gt;:\d\d = a piece of string starting with a colon and followed by two decimals (for the minutes)&lt;BR /&gt;:\d\d = a second piece of string starting with a colon and followed by two decimals (for the seconds)&lt;BR /&gt;/ = end RE&lt;BR /&gt;&lt;BR /&gt;-l = print newline after each print&lt;BR /&gt;-n = loop through input file&lt;BR /&gt;-e = program text following.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 06 Jul 2007 11:12:09 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2007-07-06T11:12:09Z</dc:date>
    <item>
      <title>F$EXTRACT Help</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056824#M84977</link>
      <description>&lt;BR /&gt;I hope this is something pretty basic but I'm having problems with F$EXTRACT break strangely on white space.&lt;BR /&gt;&lt;BR /&gt;Example of the log I am parsing:&lt;BR /&gt;Cache (HOST:20200444) Fri Jun 29 11:40:20 2007  &lt;BR /&gt;Cache (HOST:20200444) Mon Jul  2 06:22:06 2007 &lt;BR /&gt;&lt;BR /&gt;The related code snipets:&lt;BR /&gt;$ EXACT_TIME = F$ELEMENT(6," ", LOG)&lt;BR /&gt;$ MESSAGE_HOUR = F$EXTRACT(0,4,EXACT_TIME)&lt;BR /&gt;$ WRITE  SYS$OUTPUT MESSAGE_HOUR&lt;BR /&gt;&lt;BR /&gt;The output:&lt;BR /&gt;2007&lt;BR /&gt;06:2&lt;BR /&gt;&lt;BR /&gt;I wanted only the first two digits for the hour  but to ensure that F$EXTRACT was getting confused with the year, I expanded it to four digits.</description>
      <pubDate>Fri, 06 Jul 2007 08:39:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056824#M84977</guid>
      <dc:creator>Joshua Gould</dc:creator>
      <dc:date>2007-07-06T08:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: F$EXTRACT Help</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056825#M84978</link>
      <description>element 0 = Cache &lt;BR /&gt;element 1 = (HOST:20200444) &lt;BR /&gt;element 2 = Mon &lt;BR /&gt;element 3 = Jul &lt;BR /&gt;element 4 = 2 &lt;BR /&gt;element 5 = 06:22:06 &lt;BR /&gt;element 6 = 2007&lt;BR /&gt;&lt;BR /&gt;Your three lines of DCL gives 2007 as the output. Element 5 is the time. Then you could use F$ELEMENT(0,":",EXACT_TIME)&lt;BR /&gt;to get the hour.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jul 2007 09:20:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056825#M84978</guid>
      <dc:creator>Ian Miller.</dc:creator>
      <dc:date>2007-07-06T09:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: F$EXTRACT Help</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056826#M84979</link>
      <description>&lt;!--!*#--&gt;It seems to me you fail to recognize that F$ELEMENT does not recognize natural words, but simply counts every single seperator.&lt;BR /&gt;&lt;BR /&gt;I suspect that the line "jul 2" actually has an extra space, although that is not visible in this forum output.&lt;BR /&gt;If you want to pick up the 6'th word then you first have to compress mulltiple whitespace characters into 1.&lt;BR /&gt;&lt;BR /&gt;Probably something like:&lt;BR /&gt;$ log_compressed = F$EDIT(LOG,"COMPRESS")&lt;BR /&gt;$ EXACT_TIME = F$ELEMENT(6," ", log_compressed)&lt;BR /&gt;&lt;BR /&gt;Other example:&lt;BR /&gt;$ write sys$output f$ele(1," ","a b c")&lt;BR /&gt;b&lt;BR /&gt;$ write sys$output f$ele(1," ","a  b c")&lt;BR /&gt;&lt;BR /&gt;$ write sys$output f$ele(1," ",f$edit("a  b c","compress"))&lt;BR /&gt;b&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What problem are you really trying to solve?&lt;BR /&gt;I find that parsnig log file is MUCH easier in PERL or AWK once you get going a little bit with those tools.&lt;BR /&gt;&lt;BR /&gt;In this case for example:&lt;BR /&gt;&lt;BR /&gt;$ perl -lne "print $1 if /(\d+):\d\d:\d\d/" tmp.txt&lt;BR /&gt;11&lt;BR /&gt;06&lt;BR /&gt;&lt;BR /&gt;The "REGULAR EXPRESSION" /(\d+):\d\d:\d\d/ give something to match on.&lt;BR /&gt;/ = start RE&lt;BR /&gt;( = start remembering in variable $1&lt;BR /&gt;\d+ = one or more of decimals (hours)&lt;BR /&gt;) = stop remembering&lt;BR /&gt;:\d\d = a piece of string starting with a colon and followed by two decimals (for the minutes)&lt;BR /&gt;:\d\d = a second piece of string starting with a colon and followed by two decimals (for the seconds)&lt;BR /&gt;/ = end RE&lt;BR /&gt;&lt;BR /&gt;-l = print newline after each print&lt;BR /&gt;-n = loop through input file&lt;BR /&gt;-e = program text following.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jul 2007 11:12:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056826#M84979</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-07-06T11:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: F$EXTRACT Help</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056827#M84980</link>
      <description>Yes. The second white space is what threw me off. I went ahead with a solution using F$EXTRACT.</description>
      <pubDate>Fri, 06 Jul 2007 11:18:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/f-extract-help/m-p/5056827#M84980</guid>
      <dc:creator>Joshua Gould</dc:creator>
      <dc:date>2007-07-06T11:18:03Z</dc:date>
    </item>
  </channel>
</rss>

