NUMSUM(1)

๐Ÿ“ฆ
version 0.5 ยท 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

โœจ 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)


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