<?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: parse a file with expressions (*) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5446073#M640041</link>
    <description>&lt;P&gt;&amp;gt;I want to extend "awk" and want to handle: "*", "demo*", "demo"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I suggested, you convert the pattern to a ERE then try matching:&lt;/P&gt;&lt;P&gt;awk -v entry1="${entry1}" -v entry2="${entry2}" -v var="${var}" '&lt;BR /&gt;function to_ere(pattern) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; # convert from *, ? pattern to ERE, add anchors&lt;BR /&gt;&amp;nbsp;&amp;nbsp; gsub("\*", ".*", pattern)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; gsub("\?", ".", pattern)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; pattern = "^" pattern "$"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return pattern&lt;BR /&gt;}&lt;BR /&gt;$3 == var {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ere1 = to_ere($1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ere2 = to_ere($2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (entry1 ~ ere1 &amp;amp;&amp;amp; entry2 ~ ere2) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "FOUND5:", $0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}' test.cnf&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2012 03:48:21 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2012-01-10T03:48:21Z</dc:date>
    <item>
      <title>parse a file with expressions (*)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5439661#M640038</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a new question to :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/Languages-and-Scripting/parse-a-file-with-expressions-grep/m-p/5257439#M41090"&gt;parse a file with expressions (grep)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the awk is perfect:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No, "*" is easier:&lt;BR /&gt;# Pattern in test.cnf&lt;BR /&gt;# Use == for match&lt;BR /&gt;awk -v entry1="${entry1}" -v entry2="${entry2}" -v var="${var}" '&lt;BR /&gt;($1 == "*" || $1 == entry1) &amp;amp;&amp;amp;&lt;BR /&gt;($2 == "*" || $2 == entry2) &amp;amp;&amp;amp;&lt;BR /&gt;$3 == var { print "FOUND5:", $0 }' test.cnf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and handle entry in "test.cnf" like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* entry2&lt;/P&gt;&lt;P&gt;entry entry2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but how can i handle entries with&amp;nbsp; "characters*" like in "test.cnf" :&lt;/P&gt;&lt;P&gt;demo* entry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible to handle entries with "*" and "character*" ([a-z]*) and a exact entry ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2012 14:52:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5439661#M640038</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-01-05T14:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file with expressions (*)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5440899#M640039</link>
      <description>&lt;P&gt;&amp;gt;demo* entry&lt;/P&gt;&lt;P&gt;&amp;gt;is it possible to handle entries with "*" and "character*" ([a-z]*) and a exact entry?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure what you want?&amp;nbsp; Do you want to treat "*" as a normal character or as a shell pattern match?&lt;/P&gt;&lt;P&gt;Your above awk fragment treats it as a normal char but with special processing, to pretend to be a pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to do more general pattern matching, you would have to use system to invoke a shell.&lt;/P&gt;&lt;P&gt;Or you could convert that pattern into a regex an use awk's ERE to do the matching.&lt;/P&gt;&lt;P&gt;demo* (pattern) == demo.* (regex)&lt;/P&gt;&lt;P&gt;demo? (pattern) == demo. (regex)&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 15:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5440899#M640039</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-01-06T15:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file with expressions (*)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5442579#M640040</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If you want to do more general pattern matching, you would have to use system to invoke a shell.
Or you could convert that pattern into a regex an use awk's ERE to do the matching.

demo* (pattern) == demo.* (regex)
demo? (pattern) == demo. (regex)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;right, i want to extend "awk" and want to handle&lt;/P&gt;&lt;P&gt;"*"&lt;/P&gt;&lt;P&gt;"demo*"&lt;/P&gt;&lt;P&gt;"demo"&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"*" and "demo" is perfect with the awk , but how i handle like "demo*"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2012 15:01:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5442579#M640040</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-01-09T15:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file with expressions (*)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5446073#M640041</link>
      <description>&lt;P&gt;&amp;gt;I want to extend "awk" and want to handle: "*", "demo*", "demo"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I suggested, you convert the pattern to a ERE then try matching:&lt;/P&gt;&lt;P&gt;awk -v entry1="${entry1}" -v entry2="${entry2}" -v var="${var}" '&lt;BR /&gt;function to_ere(pattern) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; # convert from *, ? pattern to ERE, add anchors&lt;BR /&gt;&amp;nbsp;&amp;nbsp; gsub("\*", ".*", pattern)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; gsub("\?", ".", pattern)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; pattern = "^" pattern "$"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return pattern&lt;BR /&gt;}&lt;BR /&gt;$3 == var {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ere1 = to_ere($1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ere2 = to_ere($2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (entry1 ~ ere1 &amp;amp;&amp;amp; entry2 ~ ere2) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "FOUND5:", $0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}' test.cnf&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2012 03:48:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5446073#M640041</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-01-10T03:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file with expressions (*)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5455989#M640042</link>
      <description>&lt;P&gt;thank you very much, perfect solution with ERE ( i learn every day when you post solutions)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2012 09:52:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-with-expressions/m-p/5455989#M640042</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-01-10T09:52:58Z</dc:date>
    </item>
  </channel>
</rss>

