<?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: error in shell script code..ksh in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041540#M754909</link>
    <description>thanks for case statement..:)</description>
    <pubDate>Fri, 20 Apr 2007 08:53:21 GMT</pubDate>
    <dc:creator>amonamon</dc:creator>
    <dc:date>2007-04-20T08:53:21Z</dc:date>
    <item>
      <title>error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041526#M754895</link>
      <description>I am using ksh..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I calculated variable with bc and if I do echo $g I get: 167.500&lt;BR /&gt;&lt;BR /&gt;I would like to do check for variable $g&lt;BR /&gt;&lt;BR /&gt;in case it has value: 167.500 assign 168 to variable $h..or in case it has value 165.000 assign 165 to variable $h..here is what I did so far:&lt;BR /&gt;&lt;BR /&gt;in=$1&lt;BR /&gt;                                a=`echo "$in/5"|bc`&lt;BR /&gt;b=`expr $a + 1`&lt;BR /&gt;&lt;BR /&gt;g=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;&lt;BR /&gt;if [ $g==*000 ]&lt;BR /&gt;       then&lt;BR /&gt;      h=`echo "(($b * 123) / 100)" | bc`&lt;BR /&gt;        else&lt;BR /&gt;      h=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;value $h should be one that I look for..&lt;BR /&gt;&lt;BR /&gt;any help would be helpfull..</description>
      <pubDate>Fri, 20 Apr 2007 05:08:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041526#M754895</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T05:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041527#M754896</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;the syntax you are using is not correct.&lt;BR /&gt;&amp;gt;&amp;gt;&lt;BR /&gt;if [ $g==*000 ]&lt;BR /&gt;then&lt;BR /&gt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;You could use a 'case', but if you want a simple rounding to integer of&lt;BR /&gt;$i*1.23/5&lt;BR /&gt;my suggestion is:&lt;BR /&gt;&lt;BR /&gt;i=$1&lt;BR /&gt;h=$(print $i | awk '{printf("%.0f\n",$1*1.23/5)}')&lt;BR /&gt;print $h&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Apr 2007 06:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041527#M754896</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-20T06:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041528#M754897</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;-------&lt;BR /&gt;in case it has value: 167.500 assign 168 to variable $h..or in case it has value 165.000 assign 165 to variable $h&lt;BR /&gt;-----------&lt;BR /&gt;&lt;BR /&gt;how( and what do u mean by above) u r going to achive above by using&lt;BR /&gt;&lt;BR /&gt;-------------------&lt;BR /&gt;if [ $g==*000 ]&lt;BR /&gt;then&lt;BR /&gt;h=`echo "(($b * 123) / 100)" | bc`&lt;BR /&gt;else&lt;BR /&gt;h=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;fi&lt;BR /&gt;------------------------&lt;BR /&gt;&lt;BR /&gt;I think u have to round the figure to next integer (eg. 16.500 to 17 and 16.49 to 16)&lt;BR /&gt;is it this u want?&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Apr 2007 06:43:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041528#M754897</guid>
      <dc:creator>SANTOSH S. MHASKAR</dc:creator>
      <dc:date>2007-04-20T06:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041529#M754898</link>
      <description>ok here is again what I do have:&lt;BR /&gt;&lt;BR /&gt;# in this U enter $1&lt;BR /&gt;&lt;BR /&gt;a=`echo "$1/5"|bc`&lt;BR /&gt;b=`expr $a + 1`&lt;BR /&gt;c=`echo "$b*5"|bc`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;g=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# so by calculating g goes if statement...&lt;BR /&gt;&lt;BR /&gt;if [ $g==*000 ]&lt;BR /&gt;then&lt;BR /&gt;h=`echo "(($b * 123) / 100)" | bc`&lt;BR /&gt;else&lt;BR /&gt;h=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# this means if for example $g is 167.500 value of h will be:&lt;BR /&gt;h=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;&lt;BR /&gt;and if value od $g is 156.000 vale of h will be:&lt;BR /&gt;h=`echo "(($b * 123) / 100)" | bc`&lt;BR /&gt;&lt;BR /&gt;or more examples:&lt;BR /&gt;&lt;BR /&gt;is g is 14.145 h will be:&lt;BR /&gt;h=`echo "(($b * 123) / 100)+1" | bc`&lt;BR /&gt;&lt;BR /&gt;or if g is 45.000 h will be:&lt;BR /&gt;h=`echo "(($b * 123) / 100)" | bc`&lt;BR /&gt;&lt;BR /&gt;my problem is in syntax of if statement in this:&lt;BR /&gt;&lt;BR /&gt;if [ $g==*000 ]</description>
      <pubDate>Fri, 20 Apr 2007 07:10:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041529#M754898</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T07:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041530#M754899</link>
      <description>problem with rounding I want to solve with this is starement&lt;BR /&gt;&lt;BR /&gt;so as it says rounding will be:&lt;BR /&gt;&lt;BR /&gt;(eg. 16.500 to 17 and 16.49 to 17 again)&lt;BR /&gt;16.000 will be rounded to 16!..&lt;BR /&gt;&lt;BR /&gt;I know specific rounding..&lt;BR /&gt;It is just problem with if stat.to recognise last 3 digits..&lt;BR /&gt;//if last 3 digits are 0 if is true:&lt;BR /&gt;if [ $g==*000 ] #but this does not work</description>
      <pubDate>Fri, 20 Apr 2007 07:18:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041530#M754899</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T07:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041531#M754900</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you insist on such a construct:&lt;BR /&gt;...&lt;BR /&gt;case $g in&lt;BR /&gt;*000) # if part&lt;BR /&gt;;;&lt;BR /&gt;## possibly wanted:&lt;BR /&gt;#*[024]00) # elif round to floor&lt;BR /&gt;#;;&lt;BR /&gt;#*[68]00) # elif round to ceiling&lt;BR /&gt;#;;&lt;BR /&gt;*) # else part&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 20 Apr 2007 07:19:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041531#M754900</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-20T07:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041532#M754901</link>
      <description>well it is not that I insist..that was my solution..and it is alllwwayss very nice to hear better solution..&lt;BR /&gt;&lt;BR /&gt;thank U veryyy much</description>
      <pubDate>Fri, 20 Apr 2007 07:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041532#M754901</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T07:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041533#M754902</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;to come back to my first solution:&lt;BR /&gt;Really easy for checks (modify the formula as required, if I guessed wrong):&lt;BR /&gt;awk '{printf("%.0f\n",$1*1.23/5)}'&lt;BR /&gt;&lt;BR /&gt;Now enter you input values (stdin) and the calculated values you see on stdout.&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Apr 2007 07:30:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041533#M754902</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-20T07:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041534#M754903</link>
      <description>by the way this case is not working is always reads *) statement&lt;BR /&gt;&lt;BR /&gt;problem is he does never go in *000) check..even is $g is 123.000&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Apr 2007 07:37:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041534#M754903</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T07:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041535#M754904</link>
      <description>Thanks Peter your solution for rounding is OK..but my requirement for rounding is specific..see above post&lt;BR /&gt;&lt;BR /&gt;12.000 rounded: 12&lt;BR /&gt;12.043 rounded: 13&lt;BR /&gt;23.999 rounded: 24&lt;BR /&gt;etc.</description>
      <pubDate>Fri, 20 Apr 2007 08:05:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041535#M754904</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T08:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041536#M754905</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;then I suggest do look at the value from an integer point of view:&lt;BR /&gt;&lt;BR /&gt;awk '{printf("%d\n",$1*1.23/5)}'&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 20 Apr 2007 08:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041536#M754905</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-20T08:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041537#M754906</link>
      <description>whatever..problem is not now with rounding..it is about if or case statment...&lt;BR /&gt;after that we can deal with rounding..</description>
      <pubDate>Fri, 20 Apr 2007 08:25:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041537#M754906</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T08:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041538#M754907</link>
      <description>Sorry,&lt;BR /&gt;&lt;BR /&gt;I did not notice, that you want to round up - my last solution just drops the fractional part.&lt;BR /&gt;So better add .5 and use usual rounding:&lt;BR /&gt;awk '{printf("%.0f\n",$1*1.23/5+0.5)}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BTW: the case solution does not work due to the format your '$g' has: I don't see any fractional output in&lt;BR /&gt;print $g&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 20 Apr 2007 08:26:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041538#M754907</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-04-20T08:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041539#M754908</link>
      <description>thanks for help guys..</description>
      <pubDate>Fri, 20 Apr 2007 08:52:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041539#M754908</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T08:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: error in shell script code..ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041540#M754909</link>
      <description>thanks for case statement..:)</description>
      <pubDate>Fri, 20 Apr 2007 08:53:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-shell-script-code-ksh/m-p/5041540#M754909</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2007-04-20T08:53:21Z</dc:date>
    </item>
  </channel>
</rss>

