From owner-freebsd-questions Mon May 22 3:53:59 2000 Delivered-To: freebsd-questions@freebsd.org Received: from hq1.tyfon.net (hq1.tyfon.net [213.212.29.17]) by hub.freebsd.org (Postfix) with ESMTP id BF8FE37BF38 for ; Mon, 22 May 2000 03:53:55 -0700 (PDT) (envelope-from dl@tyfon.net) Received: from enigmatic (dan [192.168.1.20]) by hq1.tyfon.net (Postfix) with SMTP id A4EBB1C5CA; Mon, 22 May 2000 12:53:54 +0200 (CEST) From: "Dan Larsson" To: Cc: Subject: RE: calculate sum in sh Date: Mon, 22 May 2000 12:55:36 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Importance: Normal Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG | On 22-May-00 Dan Larsson wrote: | > How to I calculate the sum of all values, the | > values are listed one value per line in a textfile | > using shell commands (no perl available)? | > | Not pure shelling, but you can try this with awk | | File 'crap.txt' is : | | 1 | 2 | 3 | 20 | | then | | lagrange> awk '{sum += $0} END{print "Grand total is "sum}' crap.txt | Grand total is 26 Perfect! Thanks! | Regards ------------ Dan Larsson To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message