numtools

perform numerical operations on vectors and matrices in unix pipes
git clone git://src.adamsgaard.dk/numtools # fast
git clone https://src.adamsgaard.dk/numtools.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit 0f2c23d56a45a8cb29f973c8e551a291321bb796
parent d56b66df11a431c8d96450504bced09cfc1be98c
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed,  9 Dec 2020 11:18:22 +0100

add sum(1)

Diffstat:
Asum | 13+++++++++++++
Asum.1 | 25+++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/sum b/sum @@ -0,0 +1,13 @@ +#!/usr/bin/awk -f +{ + for (i = 0; i < NF; i++) + sum[i] = $i +} +END { + for (i = 0; i < NF; i++) { + printf("%g", sum[i]) + if (i + 1 < NF) + printf("\t") + } + printf("\n") +} diff --git a/sum.1 b/sum.1 @@ -0,0 +1,25 @@ +.Dd $Mdocdate$ +.Dt SUM 1 +.Os +.Sh NAME +.Nm sum +.Nd returns the sum for each column +.Sh SYNOPSIS +.Nm +.Op Ar file +.Sh DESCRIPTION +The +.Nm +returns the numerical sum for each column in +.Ar file +or in standard input, if no +.Ar file +is given. +Input fields must be tab-separated. +.Sh SEE ALSO +.Xr awk 1 +.Xr max 1 +.Xr mean 1 +.Xr min 1 +.Sh AUTHORS +.An Anders Damsgaard Aq Mt anders@adamsgaard.dk