[HPADM] Re: Adding up a column of number in a file

From: MuthuKumar (kmuthukumar@lycos.co.uk)
Date: Thu Dec 02 2004 - 00:35:06 EST


I need to add up a column of about 1500 number in a file. Each one is a line entry.

Example
0076.34
0003.76
0048.76
and so on

====

You can do with awk programming + printf as,

awk '{ total+=$1 } END { printf "%-.2f\n",total }' <filename>

printf "%-.2f\n",total will give,

all digits.<2 digit> float output

Regards
Muthu

--
             ---> 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:44 EDT