<?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: Can you pass vatiables to awk? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399496#M706103</link>
    <description>You can also --assign var=value on awk too.&lt;BR /&gt;&lt;BR /&gt;It is as,&lt;BR /&gt;&lt;BR /&gt; echo "hai jamie" | awk --assign server=jamie '{ if ( $1 == server ) print "OK" }' &lt;BR /&gt;&lt;BR /&gt;Else try awk -v &lt;VARIABLE&gt;=value&lt;BR /&gt;&lt;BR /&gt;see man awk.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/VARIABLE&gt;</description>
    <pubDate>Wed, 13 Oct 2004 17:08:13 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2004-10-13T17:08:13Z</dc:date>
    <item>
      <title>Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399487#M706094</link>
      <description>In a shell script:&lt;BR /&gt;&lt;BR /&gt;server=jamie&lt;BR /&gt;&lt;BR /&gt;awk '{if ($2 = $server).....&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 16:26:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399487#M706094</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-13T16:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399488#M706095</link>
      <description>Hi Jamie,&lt;BR /&gt;&lt;BR /&gt;Yes. You will have use -v flag with awk to pass them. For ex.,&lt;BR /&gt;&lt;BR /&gt;string="Sridhar"&lt;BR /&gt;echo "test" |awk -v name=$string '{print name}' &lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 13 Oct 2004 16:30:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399488#M706095</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-10-13T16:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399489#M706096</link>
      <description>I got it to work with the following as well:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($2 = "'$server'"...&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 13 Oct 2004 16:33:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399489#M706096</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-13T16:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399490#M706097</link>
      <description>Yeah.. its' the same way&lt;BR /&gt;&lt;BR /&gt;server=jamie&lt;BR /&gt;&lt;BR /&gt;awk -v server=$server '{if ($2 = $server)...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 13 Oct 2004 16:40:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399490#M706097</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-10-13T16:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399491#M706098</link>
      <description>Actually it dosn't work either way...&lt;BR /&gt;&lt;BR /&gt;Instead of the string 'jamie' I get:&lt;BR /&gt;&lt;BR /&gt;if $2 = server&lt;BR /&gt;&lt;BR /&gt;I tried it with $server and "$server" but it doesn't work...</description>
      <pubDate>Wed, 13 Oct 2004 16:47:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399491#M706098</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-13T16:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399492#M706099</link>
      <description>That's because in awk only positional variables ($1,$2, ...) get the $; all user defined variables do not use the $ prefix.&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 16:50:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399492#M706099</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-10-13T16:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399493#M706100</link>
      <description>I simply cut and pasted your line. I didn't realize you had a $ in front of $server. Look at my first example where I didn't use $ in front of 'name'.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 13 Oct 2004 16:56:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399493#M706100</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-10-13T16:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399494#M706101</link>
      <description>Yes. We can do this as,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; echo "jamie" | awk '{ if ( $1 == server ) print "ok" }' server=jamie&lt;BR /&gt;&lt;BR /&gt; It will pass that environment variable of server with jamie string there. &lt;BR /&gt;&lt;BR /&gt; You can more check as,&lt;BR /&gt;&lt;BR /&gt;  echo "hai" | awk '{ print server }' server=jamie&lt;BR /&gt;&lt;BR /&gt; HTH.&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 16:57:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399494#M706101</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-13T16:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399495#M706102</link>
      <description>Here's what I get...  (changed the variables to do a time range instead...)&lt;BR /&gt;&lt;BR /&gt;server_time="07:08:55"&lt;BR /&gt;awk -v time=$server_time {if ($9 &amp;lt; time &amp;amp;&amp;amp; $10 &amp;gt; time)&lt;BR /&gt;&lt;BR /&gt;when I debug it looks like this:&lt;BR /&gt;&lt;BR /&gt;awk -v time=07:08:55 {if ($9 &amp;lt; time &amp;amp;&amp;amp; $10 &amp;gt; time)&lt;BR /&gt;&lt;BR /&gt;shouldn't the time be replaced with the value of the time variable?</description>
      <pubDate>Wed, 13 Oct 2004 17:01:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399495#M706102</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-13T17:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399496#M706103</link>
      <description>You can also --assign var=value on awk too.&lt;BR /&gt;&lt;BR /&gt;It is as,&lt;BR /&gt;&lt;BR /&gt; echo "hai jamie" | awk --assign server=jamie '{ if ( $1 == server ) print "OK" }' &lt;BR /&gt;&lt;BR /&gt;Else try awk -v &lt;VARIABLE&gt;=value&lt;BR /&gt;&lt;BR /&gt;see man awk.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/VARIABLE&gt;</description>
      <pubDate>Wed, 13 Oct 2004 17:08:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399496#M706103</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-13T17:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399497#M706104</link>
      <description>Hi Jamie,&lt;BR /&gt;&lt;BR /&gt;Your time variable should get passed correctly but your 'test' conditions may produce unexpected results as the time variable is treated as 'text' and using &amp;lt;,&amp;gt; operators on it may not give what you expect.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 13 Oct 2004 17:23:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399497#M706104</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-10-13T17:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399498#M706105</link>
      <description>...and just to confirm that your time variable is passed correctly, put a "print time" statement in your awk script.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 13 Oct 2004 17:26:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399498#M706105</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-10-13T17:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399499#M706106</link>
      <description>I see now that the variable is getting passed corectly..  my error is now in my script.  I'm going to keep playing...&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 13 Oct 2004 17:31:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399499#M706106</guid>
      <dc:creator>Jamie Collins</dc:creator>
      <dc:date>2004-10-13T17:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can you pass vatiables to awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399500#M706107</link>
      <description>Hai Jamie,&lt;BR /&gt;&lt;BR /&gt; Started to play with awk right now. If you get your problem solved, treat responders with points to get more informations in near future and get good interaction.&lt;BR /&gt;&lt;BR /&gt;Best wishes.&lt;BR /&gt;Muthukumar.</description>
      <pubDate>Wed, 13 Oct 2004 17:34:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/can-you-pass-vatiables-to-awk/m-p/3399500#M706107</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-13T17:34:49Z</dc:date>
    </item>
  </channel>
</rss>

