<?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: regular expression in awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530011#M25035</link>
    <description>&lt;BR /&gt;If you're using a space as the FS:&lt;BR /&gt;&lt;BR /&gt;$1 ~/^2.*ANI$/ {print}&lt;BR /&gt;or&lt;BR /&gt;$1 ~/^2..abc...ANI$/ {print}&lt;BR /&gt;&lt;BR /&gt;Vincent</description>
    <pubDate>Fri, 18 May 2001 06:26:35 GMT</pubDate>
    <dc:creator>Vincent Stedema</dc:creator>
    <dc:date>2001-05-18T06:26:35Z</dc:date>
    <item>
      <title>regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530008#M25032</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;I'm using awk to search for a particular pattern in a text file. The script is very basic as I'm just trying some things currently. &lt;BR /&gt;&lt;BR /&gt;/^2..abc...ANI$/ {print "some text" }&lt;BR /&gt;&lt;BR /&gt;I save the above in a file called awktest and run it using;&lt;BR /&gt;&lt;BR /&gt;awk -f awktest inputfile&lt;BR /&gt;&lt;BR /&gt;Now the problem I am having occurs while I try and anchor the regex with the $ It doesn't produce what I'm expecting&lt;BR /&gt;&lt;BR /&gt;a sample input line in my file would be &lt;BR /&gt;&lt;BR /&gt;2lmabcXYZANI 12345 890 NO&lt;BR /&gt;&lt;BR /&gt;I just want the field "2lmabcXYZANI" but I get no output.</description>
      <pubDate>Fri, 18 May 2001 00:18:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530008#M25032</guid>
      <dc:creator>David Gartner</dc:creator>
      <dc:date>2001-05-18T00:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530009#M25033</link>
      <description>Hi David,&lt;BR /&gt;You are operating under a misconception about how awk works. In your example, the input record (line) would have to begin with '2' and the line would have to end with 'ANI'. 'ANI' in the middle of the input record does not match. What you need to do is remove the '$' and thus the input record passes the match.&lt;BR /&gt;You then would enter a block to process that line and find where your patern begins and ends and print that section. I would use the the built-in functions index or match to find the positions and substr to extract the desired positions followed by a print or printf. You just need a bit more practice with it.&lt;BR /&gt;&lt;BR /&gt;This should get you started, Clay</description>
      <pubDate>Fri, 18 May 2001 01:00:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530009#M25033</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-05-18T01:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530010#M25034</link>
      <description>try like this:&lt;BR /&gt;&lt;BR /&gt;/^2/ &amp;amp;&amp;amp; /ANI$/ {print "some text" } &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;federico&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 18 May 2001 05:55:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530010#M25034</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-05-18T05:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530011#M25035</link>
      <description>&lt;BR /&gt;If you're using a space as the FS:&lt;BR /&gt;&lt;BR /&gt;$1 ~/^2.*ANI$/ {print}&lt;BR /&gt;or&lt;BR /&gt;$1 ~/^2..abc...ANI$/ {print}&lt;BR /&gt;&lt;BR /&gt;Vincent</description>
      <pubDate>Fri, 18 May 2001 06:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530011#M25035</guid>
      <dc:creator>Vincent Stedema</dc:creator>
      <dc:date>2001-05-18T06:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530012#M25036</link>
      <description>If you like to get the first field i would use the following:&lt;BR /&gt;&lt;BR /&gt;awk '/^2..abc...ANI/ {print $1} ' inputfile&lt;BR /&gt;&lt;BR /&gt;this should give you the desired output.&lt;BR /&gt;&lt;BR /&gt;Hope the helps. Stefan</description>
      <pubDate>Fri, 18 May 2001 07:22:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530012#M25036</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2001-05-18T07:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: regular expression in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530013#M25037</link>
      <description>Use substr function of awk:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;&lt;BR /&gt;substr ( $1, 1,2 ) == "xxxx" &amp;amp;&amp;amp; substr ($1,13,4 ) { print .....}'&lt;BR /&gt;&lt;BR /&gt;See man awk for substr parameters .</description>
      <pubDate>Fri, 18 May 2001 07:45:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expression-in-awk/m-p/2530013#M25037</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-05-18T07:45:27Z</dc:date>
    </item>
  </channel>
</rss>

