Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site tove.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!mcnc!philabs!cmcl2!seismo!umcp-cs!tove!mark From: mark@tove.UUCP (Mark Weiser) Newsgroups: net.unix-wizards Subject: Re: Adding up columns of numbers. Message-ID: <154@tove.UUCP> Date: Sun, 17-Mar-85 23:31:17 EST Article-I.D.: tove.154 Posted: Sun Mar 17 23:31:17 1985 Date-Received: Fri, 22-Mar-85 02:57:53 EST References: <9273@brl-tgr.ARPA> Reply-To: mark@tove.UUCP (Mark Weiser) Organization: U of Maryland, Laboratory for Parallel Computation, C.P., MD Lines: 21 In article <9273@brl-tgr.ARPA> root%bostonu.csnet@csnet-relay.arpa (BostonU SysMgr) writes: > >P.S. One strange omission (to my knowledge) from all the UNIX tools >is a program, similar in command syntax (groan, but probably needed) >to 'sort' which adds up columns of numbers: > > sumcol +4.6 foo > >Strange, must have been written hundreds of times. >-------------------- >*End of UNIX-WIZARDS-REPLY-DIGEST-SORT-OF > > -Barry Shein, Boston University Awk is great for this. Something like: awk '{sum += $4}\\ END {print sum}' -mark -- Spoken: Mark Weiser ARPA: mark@maryland Phone: +1-301-454-7817 CSNet: mark@umcp-cs UUCP: {seismo,allegra}!umcp-cs!mark USPS: Computer Science Dept., University of Maryland, College Park, MD 20742