<?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: rounding up in awk/shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820686#M86489</link>
    <description>&lt;BR /&gt;sorry, im purely being pedandtic. I want to round up or down using awk or a shell script in a one liner if possible. You can do in C, probably in perl, but not in a simple shell script/command ?&lt;BR /&gt;</description>
    <pubDate>Tue, 08 Oct 2002 09:23:06 GMT</pubDate>
    <dc:creator>Stefan Farrelly</dc:creator>
    <dc:date>2002-10-08T09:23:06Z</dc:date>
    <item>
      <title>rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820680#M86483</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;our usual memory.sh script which uses adb and the kernel to display the system memory total works fine on 10.20 and 11.0 but on 11.11 it computes to an integer instead of a round number, eg;&lt;BR /&gt;&lt;BR /&gt;echo "phys_mem_pages/D" | adb /stand/vmunix /dev/kmem|grep phys|tail -1|awk '{printf $2/256}'&lt;BR /&gt;&lt;BR /&gt;On our server with 768Mb of RAM shows 767.992&lt;BR /&gt;&lt;BR /&gt;My question is how can we round this up in awk (should display 768) or using prinf. Ive tried but cant figure it. I know this can be done the long way in a shell script or probably in perl, definitely in C using round, but Im after a 1 liner using awk and/or printf to do it - and so that it works on servers with different memory sizes.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Stefan&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 08:54:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820680#M86483</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-10-08T08:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820681#M86484</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;echo "767.99" | awk '{printf("%d\n",$1 + 0.5);}'&lt;BR /&gt;768&lt;BR /&gt;echo "767.49" | awk '{printf("%d\n",$1 + 0.5);}'&lt;BR /&gt;767&lt;BR /&gt;echo "767.51" | awk '{printf("%d\n",$1 + 0.5);}'&lt;BR /&gt;768&lt;BR /&gt;&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Tue, 08 Oct 2002 09:00:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820681#M86484</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2002-10-08T09:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820682#M86485</link>
      <description>What about&lt;BR /&gt;&lt;BR /&gt;echo "phys_mem_pages/D" | adb /stand/vmunix /dev/kmem|tail -1|awk '{printf "%d",$2/256+.5}'&lt;BR /&gt;&lt;BR /&gt;BTW, I dropped the grep... it failed on my 11.11 box.&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 08 Oct 2002 09:03:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820682#M86485</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-10-08T09:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820683#M86486</link>
      <description>&lt;BR /&gt;Hey, come on guys, no simply adding 1 or .5 or whatever to it. I want to round up. Must be able to round with awk, or nawk, or bc or dc or bs ??? anyone ?</description>
      <pubDate>Tue, 08 Oct 2002 09:12:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820683#M86486</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-10-08T09:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820684#M86487</link>
      <description>Hmmm, Stefan.&lt;BR /&gt;&lt;BR /&gt;What's the differnence between rounding up X and rounding down (X+.5)? Why should a designer include such a redundant functionality? :)&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 08 Oct 2002 09:16:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820684#M86487</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-10-08T09:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820685#M86488</link>
      <description>why awk?&lt;BR /&gt;&lt;BR /&gt;# echo 767.992 | perl -ne'printf"%.0f\n",$_'&lt;BR /&gt;768&lt;BR /&gt;#</description>
      <pubDate>Tue, 08 Oct 2002 09:21:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820685#M86488</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-08T09:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820686#M86489</link>
      <description>&lt;BR /&gt;sorry, im purely being pedandtic. I want to round up or down using awk or a shell script in a one liner if possible. You can do in C, probably in perl, but not in a simple shell script/command ?&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 09:23:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820686#M86489</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-10-08T09:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820687#M86490</link>
      <description>Hi Procura,&lt;BR /&gt;&lt;BR /&gt;That did it! you dont need perl - your printf function is rounding perfectly (&amp;gt;.5 = up, &amp;lt; .5 round down). This now works;&lt;BR /&gt;&lt;BR /&gt;echo "phys_mem_pages/D" | adb /stand/vmunix /dev/kmem|grep phys|tail -1|awk '{printf "%.0f MB\n",$2/256}' &lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Stefan&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 09:29:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820687#M86490</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-10-08T09:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820688#M86491</link>
      <description>As far as I knwo round does not exist (in awk)&lt;BR /&gt;Well , I build it &lt;BR /&gt;You may like it or Not, just try to help&lt;BR /&gt;&lt;BR /&gt;echo $1  | awk '&lt;BR /&gt;function round(aa) {&lt;BR /&gt;return int( aa + 0.5 )&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;printf("%d\n",round($1));&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Jean-Luc&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 09:40:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820688#M86491</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2002-10-08T09:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820689#M86492</link>
      <description>Stefan,&lt;BR /&gt;&lt;BR /&gt;Thankyou for asking.  I've just been accepting the answer as is and rounding up myself.  This is much better.&lt;BR /&gt;&lt;BR /&gt;Eternally grateful,&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 08 Oct 2002 10:07:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820689#M86492</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2002-10-08T10:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820690#M86493</link>
      <description>To round up using awk:&lt;BR /&gt;echo "767.992" | awk '{printf("%5.0f\n",$0)}'&lt;BR /&gt;&lt;BR /&gt;To round down using awk:&lt;BR /&gt;echo "767.992" | awk '{printf("%d\n",$0)}'&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 12:44:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820690#M86493</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2002-10-08T12:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820691#M86494</link>
      <description>To be more specific in my previous post, Using %5.0f actually will properly round the number up or down as expected.  Using %d simply truncates off the decimals printing only the integer portion.&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 12:53:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820691#M86494</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2002-10-08T12:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820692#M86495</link>
      <description>Isn't the forum great...&lt;BR /&gt;I had the same question and found my answer(s) right here using search.  Thanks, Stephen</description>
      <pubDate>Wed, 04 Dec 2002 19:14:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820692#M86495</guid>
      <dc:creator>Stephen Serbe</dc:creator>
      <dc:date>2002-12-04T19:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up in awk/shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820693#M86496</link>
      <description>Psssst - Stephen!!!  That's Stefan!&lt;BR /&gt;&lt;BR /&gt;;^)&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Wed, 04 Dec 2002 19:16:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/rounding-up-in-awk-shell/m-p/2820693#M86496</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2002-12-04T19:16:15Z</dc:date>
    </item>
  </channel>
</rss>

