<?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: bc in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660587#M48296</link>
    <description>Thanks Everyone,&lt;BR /&gt;Lots of great ideas that I will use.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Again,&lt;BR /&gt;Bob</description>
    <pubDate>Thu, 07 Feb 2002 15:19:07 GMT</pubDate>
    <dc:creator>Nobody's Hero</dc:creator>
    <dc:date>2002-02-07T15:19:07Z</dc:date>
    <item>
      <title>bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660579#M48288</link>
      <description>Good Morning,&lt;BR /&gt;I have written a script that reads a log file, calls 'ex' to edit what I need. Then I gather some backup stats and I need to do some division. How can I use bc in a script to devide, lets say, 400GB took 12 hours. Can I just call 'bc' and do the math?&lt;BR /&gt;bc&lt;BR /&gt;400 / 12  &lt;BR /&gt;Or is there another way to calculate numbers?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Bob</description>
      <pubDate>Thu, 07 Feb 2002 12:20:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660579#M48288</guid>
      <dc:creator>Nobody's Hero</dc:creator>
      <dc:date>2002-02-07T12:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660580#M48289</link>
      <description>Robert,&lt;BR /&gt;&lt;BR /&gt;Check this out:&lt;BR /&gt;&lt;BR /&gt;bdf | grep -v Filesystem|grep vg02 | tr -s "  " " "|cut -d" " -f 3 | sort -n | xargs echo | sed "s/ / + /g" | bc&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;echo `ls -l /tmp/va4_ioscan`"\nx x x x .65" | tr -s "  " " "|cut -d" " -f 5 | xargs echo | sed "s/ / \* /g"|bc|cut -d"." -f1|sed "s/$/ \/ 512 /"|bc|sed "s:^:dd if=/t&lt;BR /&gt;mp/va4_ioscan of=/tmp/stewcount=:" | sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Feb 2002 12:25:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660580#M48289</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-02-07T12:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660581#M48290</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;bc can used ie:&lt;BR /&gt;&lt;BR /&gt;value=400&lt;BR /&gt;result=`echo "scale=2\n$value/12"|bc`&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 07 Feb 2002 12:31:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660581#M48290</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-02-07T12:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660582#M48291</link>
      <description>Hi Robert,&lt;BR /&gt;&lt;BR /&gt;there are some more ways to calculate:&lt;BR /&gt;&lt;BR /&gt;1) the "expr" command, has the following syntax: expr nr1 operator nr2&lt;BR /&gt;possible operators are: addition +&lt;BR /&gt;                        subtraction -&lt;BR /&gt;                        multiplication \*&lt;BR /&gt;                        division /&lt;BR /&gt;for example: expr 2 \* 5 &lt;BR /&gt;# 10&lt;BR /&gt;&lt;BR /&gt;please remember, this command can only calculate integers, so expr 10 / 6 would deliver an output of 1 !&lt;BR /&gt;&lt;BR /&gt;2) (( nr1 operator nr2 )), has the same functions than expr, but is done a lot of faster. Same limitations than expr, no floating point!&lt;BR /&gt;&lt;BR /&gt;3) awk has also a lot of numeric builtin- functions. To use it with variable=value, you call it awk -v variable=value, then the variable is a predefined in the awk- program. The awk- command has some numeric functions which can handle floating point.&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Thu, 07 Feb 2002 12:34:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660582#M48291</guid>
      <dc:creator>Peter Kloetgen</dc:creator>
      <dc:date>2002-02-07T12:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660583#M48292</link>
      <description>Hi Bob,&lt;BR /&gt;&lt;BR /&gt;If you have perl:&lt;BR /&gt;&lt;BR /&gt;perl -e 'print (eval ($ARGV[0]),"\n")' 400/12&lt;BR /&gt;33.3333333333333&lt;BR /&gt;&lt;BR /&gt;or whatever.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 07 Feb 2002 12:46:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660583#M48292</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-02-07T12:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660584#M48293</link>
      <description>Robert,&lt;BR /&gt;&lt;BR /&gt;If you use the "-l" (dash-el) option, you get a decimals:&lt;BR /&gt;&lt;BR /&gt;[root]pbctst: echo "400 / 12" | bc -l&lt;BR /&gt;33.33333333333333333333&lt;BR /&gt;[root]pbctst:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 07 Feb 2002 12:53:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660584#M48293</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-02-07T12:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660585#M48294</link>
      <description>Hi Robert:&lt;BR /&gt;&lt;BR /&gt;'bc' works quite well.  For decimal numbers, include the "scale":&lt;BR /&gt;&lt;BR /&gt;# X=1;Y=8;echo "scale=3\n $X/$Y"|bc&lt;BR /&gt;&lt;BR /&gt;I, too, like 'awk' given its ability to format and produce output in different number bases:&lt;BR /&gt;&lt;BR /&gt;# X=1;Y=8;echo "$X $Y"|awk '{printf "%.4f\n",$1/$2}'&lt;BR /&gt;&lt;BR /&gt;# X=7;Y=8;echo "$X $Y"|awk '{printf "%4x\n",$1+$2}'&lt;BR /&gt;&lt;BR /&gt;For simple integer arithmetic, you can use the shell 'let':&lt;BR /&gt;&lt;BR /&gt;# let A=100;let B=8;let C=$A/$B;echo $C&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Thu, 07 Feb 2002 13:00:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660585#M48294</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-02-07T13:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660586#M48295</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BC is fine. &lt;BR /&gt;&lt;BR /&gt;Example&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#You could use the 'two way pipe' to the program to do all your math operations,&lt;BR /&gt; like this:&lt;BR /&gt;# This starts bc with a two-way pipe&lt;BR /&gt;bc |&amp;amp;&lt;BR /&gt;# print -p writes to the pipe&lt;BR /&gt;print -p scale=4&lt;BR /&gt;print -p 3/4&lt;BR /&gt;# read -p reads from the pipe&lt;BR /&gt;read -p myvar&lt;BR /&gt;echo $myvar&lt;BR /&gt;&lt;BR /&gt;  bc tutorial in Number Processing Users Guide&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;          Steve Steel</description>
      <pubDate>Thu, 07 Feb 2002 13:42:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660586#M48295</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-02-07T13:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: bc</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660587#M48296</link>
      <description>Thanks Everyone,&lt;BR /&gt;Lots of great ideas that I will use.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Again,&lt;BR /&gt;Bob</description>
      <pubDate>Thu, 07 Feb 2002 15:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bc/m-p/2660587#M48296</guid>
      <dc:creator>Nobody's Hero</dc:creator>
      <dc:date>2002-02-07T15:19:07Z</dc:date>
    </item>
  </channel>
</rss>

