<?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: script variables within awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151009#M900892</link>
    <description>awk -v would be the solution , I don;t know why you don't want to use it !&lt;BR /&gt;&lt;BR /&gt;Nevertheless, you can run something like :&lt;BR /&gt;(echo 90 &amp;amp;&amp;amp; echo 95 &amp;amp;&amp;amp; bdf) | &lt;BR /&gt;awk 'BEGIN{getline; th1=$0; getline; th2=$0; }&lt;BR /&gt;{print $1,th1,th2;}'&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc</description>
    <pubDate>Tue, 23 Dec 2003 05:00:44 GMT</pubDate>
    <dc:creator>Jean-Luc Oudart</dc:creator>
    <dc:date>2003-12-23T05:00:44Z</dc:date>
    <item>
      <title>script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3150998#M900881</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I use variables within a script and I would like to use them within an awk command without the -v option.&lt;BR /&gt;For example:&lt;BR /&gt;THRESHOLD1=90&lt;BR /&gt;THRESHOLD2=95&lt;BR /&gt;bdf | awk '{print $1, ":$THRESHOLD1:$THRESHOLD2"}' &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;I know this would work: &lt;BR /&gt;bdf | awk -v thr1=$THRESHOLD1 -v thr2=$THRESHOLD2 '{print $1, ":thr1:thr2"}' &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;but I am looking for something... smarter.&lt;BR /&gt;&lt;BR /&gt;Can someone help me?</description>
      <pubDate>Mon, 22 Dec 2003 11:23:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3150998#M900881</guid>
      <dc:creator>Sylvain CROUET</dc:creator>
      <dc:date>2003-12-22T11:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3150999#M900882</link>
      <description>perform a "print" of the line "bdf | awk '{print $1, $THRESHOLD1:$THRESHOLD2"}' " and redirect to a temporary file. Then run that file using the 'sh' command.&lt;BR /&gt;&lt;BR /&gt;This is helpful if the number of variables to ber passed is not known&lt;BR /&gt;&lt;BR /&gt;Alternatively you can string these variables together to pass only 1 variable to the awk statement!&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Dec 2003 11:32:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3150999#M900882</guid>
      <dc:creator>ian Dennison</dc:creator>
      <dc:date>2003-12-22T11:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151000#M900883</link>
      <description>I prefer the second solution.</description>
      <pubDate>Mon, 22 Dec 2003 11:34:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151000#M900883</guid>
      <dc:creator>Sylvain CROUET</dc:creator>
      <dc:date>2003-12-22T11:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151001#M900884</link>
      <description>Using "-v" is the standard awk mechanism for passing variables. You could use "perl" instead.&lt;BR /&gt; &lt;BR /&gt;bdf | perl -nae 'print "$F[0]:$ENV{THRESHOLD1}:$ENV{THRESHOLD2}' &amp;gt;FILE&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 22 Dec 2003 11:42:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151001#M900884</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-12-22T11:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151002#M900885</link>
      <description>depends on which version of awk your running,&lt;BR /&gt;if it is a newer version, such as on an 11i system, you can use the ENVIRON array to access the values&lt;BR /&gt;&lt;BR /&gt;export THRESHOLD1=90&lt;BR /&gt;export THRESHOLD2=95&lt;BR /&gt;bdf | awk '{print "$1, :ENVIRON[THRESHOLD1]:ENVIRON[THRESHOLD2]";}' &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and of course you can also pass values to awk using the command line via argc and argv somewhat like a c program</description>
      <pubDate>Mon, 22 Dec 2003 11:45:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151002#M900885</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-12-22T11:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151003#M900886</link>
      <description>Interesting ideas but I do not have very recent servers and perl is not installed on all machines.</description>
      <pubDate>Mon, 22 Dec 2003 11:48:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151003#M900886</guid>
      <dc:creator>Sylvain CROUET</dc:creator>
      <dc:date>2003-12-22T11:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151004#M900887</link>
      <description>you'll need double qoutes around the variable name&lt;BR /&gt;&lt;BR /&gt;ENVIRON["THRESHOLD1"]&lt;BR /&gt;&lt;BR /&gt;and you don't have to export the variables;&lt;BR /&gt;export THRESHOLD1=90</description>
      <pubDate>Mon, 22 Dec 2003 11:49:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151004#M900887</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-12-22T11:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151005#M900888</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;believe Curt, environ is what you need to evaluate envoronment variables from within awk. See man awk.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Dec 2003 15:47:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151005#M900888</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-12-22T15:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151006#M900889</link>
      <description>Yes, ENVIRON seems to be what I need, but my Solaris machines do not seem to implement a correct version of awk as there is no ENVIRON variable within the awk manual page and it does not work as it does under HP-UX.</description>
      <pubDate>Tue, 23 Dec 2003 04:13:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151006#M900889</guid>
      <dc:creator>Sylvain CROUET</dc:creator>
      <dc:date>2003-12-23T04:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151007#M900890</link>
      <description>On Solaris you may try /usr/xpg4/bin/awk instead.</description>
      <pubDate>Tue, 23 Dec 2003 04:19:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151007#M900890</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-12-23T04:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151008#M900891</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;can you post an example and why it does not work, i mean any error messages?&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Dec 2003 04:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151008#M900891</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-12-23T04:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151009#M900892</link>
      <description>awk -v would be the solution , I don;t know why you don't want to use it !&lt;BR /&gt;&lt;BR /&gt;Nevertheless, you can run something like :&lt;BR /&gt;(echo 90 &amp;amp;&amp;amp; echo 95 &amp;amp;&amp;amp; bdf) | &lt;BR /&gt;awk 'BEGIN{getline; th1=$0; getline; th2=$0; }&lt;BR /&gt;{print $1,th1,th2;}'&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Tue, 23 Dec 2003 05:00:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151009#M900892</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2003-12-23T05:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151010#M900893</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;there is an alternativ to environ. Store the values of the environment variables into a file and then read them ony by one.&lt;BR /&gt;&lt;BR /&gt;getline &amp;lt; extvarfile; var1=$0;&lt;BR /&gt;getline &amp;lt; extvarfile; var2=$0;&lt;BR /&gt;&lt;BR /&gt;greetings&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Dec 2003 05:23:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151010#M900893</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-12-23T05:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151011#M900894</link>
      <description>I finally used Ian's solution; but Curt's solution, with the precision brougth by Dietmar, works fine too.</description>
      <pubDate>Tue, 23 Dec 2003 06:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151011#M900894</guid>
      <dc:creator>Sylvain CROUET</dc:creator>
      <dc:date>2003-12-23T06:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151012#M900895</link>
      <description>It's all in the quoting.  You could do this:&lt;BR /&gt;&lt;BR /&gt;THRESHOLD1=90&lt;BR /&gt;THRESHOLD2=95&lt;BR /&gt;bdf | awk "{print \$1, \":$THRESHOLD1:$THRESHOLD2\"}" &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JL</description>
      <pubDate>Tue, 23 Dec 2003 08:48:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151012#M900895</guid>
      <dc:creator>James Lynch</dc:creator>
      <dc:date>2003-12-23T08:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: script variables within awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151013#M900896</link>
      <description>I am going to show two other suggestions that didn't show up in the thread.&lt;BR /&gt;&lt;BR /&gt;THRESHOLD1=90&lt;BR /&gt;THRESHOLD2=95&lt;BR /&gt;bdf | awk '{print $1, ":"THRESHOLD1":"THRESHOLD2}' THRESHOLD1=$THRESHOLD1 THRESHOLD2=$THRESHOLD2 &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;bdf | awk '{print $1, ":"THRESHOLD1":"THRESHOLD2}' THRESHOLD1=90 THRESHOLD2=95 &amp;gt; FILE&lt;BR /&gt;&lt;BR /&gt;Rory&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Dec 2003 11:34:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-variables-within-awk/m-p/3151013#M900896</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2003-12-23T11:34:42Z</dc:date>
    </item>
  </channel>
</rss>

