<?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: ksh variables inside awk script inside ksh script ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907302#M702533</link>
    <description>awk -v &lt;BR /&gt;&lt;BR /&gt;Anil</description>
    <pubDate>Tue, 14 Jun 2005 15:54:46 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2005-06-14T15:54:46Z</dc:date>
    <item>
      <title>ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907300#M702531</link>
      <description>Consider this ksh script:&lt;BR /&gt;&lt;BR /&gt;SIZES= 3 4325 8632 160000&lt;BR /&gt;&lt;BR /&gt;for Size in $SIZES&lt;BR /&gt;do&lt;BR /&gt;        awk '&lt;BR /&gt;        $NF == $Size    { Count = Count + 1&lt;BR /&gt;                          Total = Total + $NF }&lt;BR /&gt;        END             { TotGB = Total / 1000&lt;BR /&gt;                          printf ("%8d %6d %6d GB \n", $NF, Count, TotGB) }&lt;BR /&gt;        ' $SYMDEV.1&lt;BR /&gt;done &amp;gt; $SYMDEV.2&lt;BR /&gt;&lt;BR /&gt;I can't get the $Size inside the awk to substitute into a 3, 4315, etc.&lt;BR /&gt;&lt;BR /&gt;How do i do that?&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2005 15:34:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907300#M702531</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-06-14T15:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907301#M702532</link>
      <description>not an awk/sed expert here but you seem to be missing a "{" in this whole thing. I am not sure if it is the problem, but if not, try escaping the "$" character in front of variable size by a "\", i.e., replace "$Size" with "\$Size"&lt;BR /&gt;&lt;BR /&gt;Hope this helps...</description>
      <pubDate>Tue, 14 Jun 2005 15:54:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907301#M702532</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-06-14T15:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907302#M702533</link>
      <description>awk -v &lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Tue, 14 Jun 2005 15:54:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907302#M702533</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-06-14T15:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907303#M702534</link>
      <description>You are expecting the shell to instantiate variables within single quotes --- that ain't gonna happen but what you could do is something like this:&lt;BR /&gt;awk -v Size=${Size} '$NF == Size ....'&lt;BR /&gt;&lt;BR /&gt;The -v Size=${SIZE} create an awk variable 'Size' (not $Size inside awk) and gives it the value of the shell variable ${Size}.&lt;BR /&gt;&lt;BR /&gt;I've intentionally not done everything for you.</description>
      <pubDate>Tue, 14 Jun 2005 15:59:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907303#M702534</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-06-14T15:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907304#M702535</link>
      <description>Stuart,&lt;BR /&gt;&lt;BR /&gt;You need to replace the single ticks with double quotes in your awk script otherwise variable expansion will not occur. Also change the double quotes of your printf statement to single quotes so that awk can correctly parse your statements.&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Tue, 14 Jun 2005 18:54:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907304#M702535</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-06-14T18:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907305#M702536</link>
      <description>Hi Stuart,&lt;BR /&gt;&lt;BR /&gt;Try this with -v option&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SIZES= 3 4325 8632 160000&lt;BR /&gt;&lt;BR /&gt;for Size in $SIZES&lt;BR /&gt;do&lt;BR /&gt;awk -v NF=$Size '&lt;BR /&gt;{ Count = Count + 1&lt;BR /&gt;Total = Total + $NF }&lt;BR /&gt;END { TotGB = Total / 1000&lt;BR /&gt;printf ("%8d %6d %6d GB \n", $NF, Count, TotGB) }&lt;BR /&gt;' $SYMDEV.1&lt;BR /&gt;done &amp;gt; $SYMDEV.2&lt;BR /&gt;&lt;BR /&gt;Should work&lt;BR /&gt;&lt;BR /&gt;Cheers !!!&lt;BR /&gt;eknath</description>
      <pubDate>Tue, 14 Jun 2005 23:57:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907305#M702536</guid>
      <dc:creator>Eknath</dc:creator>
      <dc:date>2005-06-14T23:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: ksh variables inside awk script inside ksh script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907306#M702537</link>
      <description>awk -v Size=$Size '&lt;BR /&gt;$NF == Size {Count = Count +1 ...</description>
      <pubDate>Wed, 15 Jun 2005 10:26:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-variables-inside-awk-script-inside-ksh-script/m-p/4907306#M702537</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-06-15T10:26:39Z</dc:date>
    </item>
  </channel>
</rss>

