<?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: awk behaviour in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185226#M682973</link>
    <description>Hi (again) Wout:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Any idea why I got this output ? Or should we just classify it under 'unexpected behaviour' :-)&lt;BR /&gt;&lt;BR /&gt;Yes, read my second post.  Using ~/^PAT/ means to match a constant, not evaulate.  Notice how we dropped the '/'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Fri, 03 Jul 2009 13:03:33 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-07-03T13:03:33Z</dc:date>
    <item>
      <title>awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185221#M682968</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Long time no see ;-)&lt;BR /&gt;I'm encountering some puzzling awk behaviour.&lt;BR /&gt;&lt;BR /&gt;This is my (example) source file:&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;/home/jagersw &amp;gt; cat tst&lt;BR /&gt;021F 021F&lt;BR /&gt;0400 0400&lt;BR /&gt;04E2 04E2&lt;BR /&gt;012A 012A&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;I'd like to ask awk to find me the 2nd field for any given 1st one, using a variable.&lt;BR /&gt;&lt;BR /&gt;However, what seems to work most of the time gives me grief at some occasions.&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;/home/jagersw &amp;gt; R1CHK="021F"&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; awk -v r1chk="$R1CHK" '$1==r1chk{print $2}' tst&lt;BR /&gt;021F&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; R1CHK="012A"&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; awk -v r1chk="$R1CHK" '$1==r1chk{print $2}' tst&lt;BR /&gt;012A&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;That's obviously what I want. Very nice.&lt;BR /&gt;&lt;BR /&gt;However, with some values it doesn't seem to work:&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;/home/jagersw &amp;gt; R1CHK="04E2"&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; awk -v r1chk="$R1CHK" '$1==r1chk{print $2}' tst&lt;BR /&gt;0400&lt;BR /&gt;04E2&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; R1CHK="0400"&lt;BR /&gt;&lt;BR /&gt;/home/jagersw &amp;gt; awk -v r1chk="$R1CHK" '$1==r1chk{print $2}' tst&lt;BR /&gt;0400&lt;BR /&gt;04E2&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;I'm puzzled. Maybe I just didn't get enough sleep last night, but I can't think of an explanation for this.&lt;BR /&gt;&lt;BR /&gt;Anyone up for enlightening me ?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance !&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Wout</description>
      <pubDate>Fri, 03 Jul 2009 12:42:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185221#M682968</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-03T12:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185222#M682969</link>
      <description>11.31 on ia64</description>
      <pubDate>Fri, 03 Jul 2009 12:43:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185222#M682969</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-03T12:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185223#M682970</link>
      <description>Hi Wout:&lt;BR /&gt;&lt;BR /&gt;You are close:&lt;BR /&gt;&lt;BR /&gt;# awk -v PAT="0400" '$1~PAT {print $2}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 03 Jul 2009 12:52:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185223#M682970</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-03T12:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185224#M682971</link>
      <description>Hi (again) Wout:&lt;BR /&gt;&lt;BR /&gt;I meant to add that the tilde allows the righthand side to be a constant (a sequence of characters between slashes) or an expression which can be evaulated.  Here, we the evaulation to occur.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 03 Jul 2009 12:55:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185224#M682971</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-03T12:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185225#M682972</link>
      <description>Thanks James !!&lt;BR /&gt;&lt;BR /&gt;# awk -v PAT="0400" '$1~PAT {print $2}' file&lt;BR /&gt;&lt;BR /&gt;Naturally I've tried a bunch of things (even ~/^PAT/), except this.&lt;BR /&gt;&lt;BR /&gt;Works excellent now.&lt;BR /&gt;&lt;BR /&gt;Any idea why I got this output ? Or should we just classify it under 'unexpected behaviour' :-)&lt;BR /&gt;&lt;BR /&gt;Thanks again !&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Wout</description>
      <pubDate>Fri, 03 Jul 2009 12:59:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185225#M682972</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-03T12:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185226#M682973</link>
      <description>Hi (again) Wout:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Any idea why I got this output ? Or should we just classify it under 'unexpected behaviour' :-)&lt;BR /&gt;&lt;BR /&gt;Yes, read my second post.  Using ~/^PAT/ means to match a constant, not evaulate.  Notice how we dropped the '/'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 03 Jul 2009 13:03:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185226#M682973</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-03T13:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185227#M682974</link>
      <description>Indeed, that got cross-posted.&lt;BR /&gt;Thanks a bunch !&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Wout</description>
      <pubDate>Fri, 03 Jul 2009 13:07:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185227#M682974</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-03T13:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185228#M682975</link>
      <description>&amp;gt;with some values it doesn't seem to work: R1CHK="04E2"&lt;BR /&gt;&amp;gt;0400 04E2&lt;BR /&gt;&lt;BR /&gt;My first thought was that you are mixing chars vs numbers.  You shouldn't need no stinkin' ~ to be able to get a string exact match.&lt;BR /&gt;&lt;BR /&gt;Looking closely at your output, 0400 and 04E2 ARE equal numerically!&lt;BR /&gt;&lt;BR /&gt;So you need to convert to strings:&lt;BR /&gt;'$1 == r1chk "" {print $2}'&lt;BR /&gt;Or:&lt;BR /&gt;'BEGIN { r1chk = r1chk "" }&lt;BR /&gt;$1 == r1chk {print $2}'&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Anyone up for enlightening me?&lt;BR /&gt;&lt;BR /&gt;It looks like nobody did.&lt;BR /&gt;Perhaps this is why you should use grep then awk.  :-)</description>
      <pubDate>Sat, 04 Jul 2009 05:47:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185228#M682975</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-04T05:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185229#M682976</link>
      <description>Nice, concatenating a quote or zero for conversion was new to me, thanks for pointing this out !&lt;BR /&gt;&lt;BR /&gt;How exactly are these the same, numerically ? I don't seem to experience the same issue with values like 04E4 or 012E ..?&lt;BR /&gt;&lt;BR /&gt;Thanks for the continued enlightenment ;-)&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Jul 2009 18:31:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185229#M682976</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-04T18:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185230#M682977</link>
      <description>&amp;gt;concatenating a quote or zero for conversion&lt;BR /&gt;&lt;BR /&gt;I've seen awk scripts where they do "x + 0" to do the opposite.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;How exactly are these the same, numerically?&lt;BR /&gt;&lt;BR /&gt;Scientific notation: 04E2 is 4 * 10**2 == 400</description>
      <pubDate>Sun, 05 Jul 2009 02:13:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185230#M682977</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-05T02:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: awk behaviour</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185231#M682978</link>
      <description>Of course :-)&lt;BR /&gt;Thanks again !</description>
      <pubDate>Sun, 05 Jul 2009 06:46:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-behaviour/m-p/5185231#M682978</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2009-07-05T06:46:49Z</dc:date>
    </item>
  </channel>
</rss>

