NUMSUM(1)
โจ NUMSUM ๐
okay bestie, so this is numsum โ a user-contributed Perl doc situation, and honestly? it's giving calculator but make it a whole Unix tool ๐งฎโจ
๐ธ NAME ๐ธ
numsum โ the numsum program, file edition. that's it, that's the name, she's simple and she knows it ๐
๐ SYNOPSIS ๐
numsum [-iIcdhrsvxy] <FILE>
| numsum [-iIcdhrsvxy] (Input on STDIN from pipeline.)
numsum [-iIcdhrsvxy] (Input on STDIN. Use Ctrl-D to stop.)
so yeah, three whole ways to feed her: hand her a <FILE>, pipe stuff in from a pipeline, or just run her raw and type numbers at her until you hit Ctrl-D to stop. iconic behavior honestly ๐
๐ฆ DESCRIPTION ๐ฆ
okay so here's the tea: numsum takes all the numbers on stdin and returns the sum of those numbers. that's the whole vibe. addition. slay.
but wait, there's lore ๐ซถ โ currently she only processes the first number on each line (unless you're using the -x option, more on that below, iykyk).
and bestie she's not basic โ besides positive numbers, she also handles negative numbers and numbers with decimals. versatile queen ๐
๐ OPTIONS ๐
-iโ only return the integer portion of the final sum. decimals? not today ๐-Iโ only return the decimal portion of the final sum. integers? also not today ๐-cโ print out the sum of each column.-rโ print out the sum of each row.-x <n>โ specify a comma separated list of columns to print.-y <n>โ specify a comma separated list of rows to print.-s <string>โ specify a string to use as a separator for columns. this defaults to consecutive whitespace (\s+).-hโ Help: you're literally looking at it rn ๐ญ-Vโ increase verbosity.-dโ Debug mode. for developers ๐ฉโ๐ป-qโ Quiet mode, don't print any warnings. shhh ๐คซ
๐ EXAMPLES ๐
simply add up the numbers in a file โจ
$ numsum numbers.txt
4315
enter your own numbers on STDIN. the last number is the answer ๐
$ numsum
4
21
98
100
223
use it in a command pipeline ๐ฅ
$ ls -1s | grep .mp3 | numsum -c -x 5
72288
add up the total byte count in a http log file ๐
$ cat access_log | awk {'print $10'} numsum
or
numsum -c -x 10 access_log
add up the columns of numbers of a file ๐ง
$ cat columns
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
$ numsum -c columns
15 40 65 90 115
add up the 1st, 2nd and 5th columns only ๐
$ numsum -c -x 1,2,5 columns
15 40 115
add up the rows of numbers of a file ๐ธ
$ numsum -r columns
55
60
65
70
75
add up the 2nd and 4th rows ๐ฆ
$ numsum -r -y 2,4 columns
60
70
๐ SEE ALSO ๐
go give her besties some love too, they're all part of the same friend group:
numaverage(1), numbound(1), numinterval(1), numnormalize(1), numgrep(1), numprocess(1), numrandom(1), numrange(1), numround(1)
๐ COPYRIGHT ๐
numsum is part of the num-utils package, which is copyrighted by Suso Banderas and released under the GPL license. please read the COPYING and LICENSE files that came with the num-utils package ๐
developers can read the GOALS file and contact me about providing submitions or help for the project. (yes, it says submitions in the original, i'm not touching that, it's canon now ๐)
๐ MORE INFO ๐
more info on numsum can be found at:
http://suso.suso.org/xulu/Num-utils
perl v5.30.3 ยท 2020-06-09 โ that's the version and the date bestie, this doc is a lil vintage and we love her for it ๐
okay that's the whole page, go sum some numbers, you're gonna eat ๐ซถโจ
๐ฆ where this page comes from
- debian bookworm: num-utils 0.5-15 ยท GPL-2.0-or-later
- debian trixie: num-utils 0.5-15 ยท GPL-2.0-or-later
- ubuntu jammy: num-utils 0.5-15 ยท GPL-2.0-or-later
- ubuntu noble: num-utils 0.5-15 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms