[HPADM] summary: script or bc question

From: Rasheed Tamton (Contractor) (Rasheedt@stc.com.sa)
Date: Mon Jul 15 2002 - 07:08:18 EDT


Hi admins,

I owe an old summary to the list. I was on a short vac. and also did not get
enough time to test all the replies. Though my question was to get an answer
related to bc most of them have advised me to use awk with sum instead of bc
which I used to do before. I still would like to get an answer reg. bc
though it is not important but just to satisfy my mind. Also, does anyone
have a smart script which gets the exact total of a bdf output, if in case
the bdf output lines go to more than one line. In such case the column
number differs to two instead of three and you get a wrong output.

Thanks very much to the following who responded to my query in many ways to
help me.

Joel Taqueban [joelt@apis.dhl.com]
Baran YURDAGUL [barany@netas.com.tr]
Stefano Unternaehrer [stefano.unternaehrer@ti.ch]
Steve Holdoway [sholdowa@hotmail.com]
George_Abraham [George_A@Satyam.com]
Raju.Pillai@uktransco.com
Bill Hassell
Thierry ITTY [thierry.itty@besancon.org]
Bart Vetters [bart.vetters@oma.be]
Bob Vance [BVance@sbm.com]
Goodwin, Richard [Richard.Goodwin@Staples.com]

TOTSCH,DAVID (HP-USA,ex3) [david_totsch@hp.com] who pointed out the problem
of bdf output wrapping to the next line - very important if you are looking
for an accurate result

Eef Hartman [hartman@mf.twi.tudelft.nl]
RobertDill@pvh.com

I can get the result from the below command for a normal bdf output.

bdf |grep dev | awk '{SUM +=$3}END{printf"%-15d\n",SUM}'

As I said above, I am looking for a bc solution also.

Regards,
Rasheed.

-----Original Message-----
From: Rasheed Tamton (Contractor) [mailto:Rasheedt@stc.com.sa]
Sent: 25 March, 2002 3:20 AM
To: hpux-admin@dutchworks.nl
Subject: [HPADM] script or bc question
Importance: High

Hi Admins,

I have a small file which contains a single column of numbers as below (
which I got using the command; bdf |grep dev | awk '{print $3}' ):

67894
22023
875785
275798
394206

My question is how I can direct these numbers to bc to calculate the column
values and get the correct answer. For example, I need a plus sign after
each value for bc, to be able to calculate (as far as I know!). Or any easy
solution to solve this.

like this:
echo " 67894 + 22023 + 875785 + 275798 + 394206 " | bc

Can anybody help me in this regard.

Thanks in adv.
Rasheed.

--
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:16 EDT