[ale] Shell script

Prasanna P Subash psubash at turbolinux.com
Wed Sep 27 17:57:14 EDT 2000


I'm sure there are better ways to do this but this works for me

psubash at psubash:/tmp--()
>>>>>cat 2.txt
-45.55
1200
-34.55
4.5
100.34
psubash at psubash:/tmp--()
>>>>>cat 2.txt | xargs echo | sed "s/ /\ +\ /g" > /tmp/3.txt ; echo quit >> /tmp/3.txt ; bc /tmp/3.txt
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1224.74
psubash at psubash:/tmp--()
>>>>>

On Wed, Sep 27, 2000 at 05:09:59PM -0400, Brian J. Dowd wrote:
> Does anyone have a bash script which will
> sum all the numbers in a file?
> They aren't integers (which rules out 'expr')
> Each is on a separate line. Example:
> -45.23
> 55.6
> 123.44
> ...
> I can't seem to make 'bc' work...
> 
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.

-- 

Prasanna P Subash
Software Engineer
TurboLinux, Inc

psubash at turbolinux.com

 PGP signature




More information about the Ale mailing list