aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile4
-rw-r--r--README.markdown1
-rw-r--r--bin/tot.awk3
-rw-r--r--man/man1/tot.1df19
5 files changed, 27 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 261cb22c..2c570bee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ bin/rndi
bin/sd2u
bin/slsf
bin/su2d
+bin/tot
bin/unf
games/acq
games/kvlt
diff --git a/Makefile b/Makefile
index d83d3dba..47bb3891 100644
--- a/Makefile
+++ b/Makefile
@@ -72,6 +72,7 @@ all : bin/han \
bin/sd2u \
bin/slsf \
bin/su2d \
+ bin/tot \
bin/unf \
git/gitconfig \
gnupg/gpg.conf \
@@ -85,6 +86,7 @@ clean distclean :
bin/sd2u \
bin/slsf \
bin/su2d \
+ bin/tot \
bin/unf \
games/acq \
games/kvlt \
@@ -169,7 +171,7 @@ install-bash-completion : install-bash
install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion
install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d
-install-bin : bin/han bin/sd2u bin/su2d bin/unf check-bin install-bin-man
+install-bin : bin/han bin/sd2u bin/su2d bin/tot bin/unf check-bin install-bin-man
install -m 0755 -d -- "$(HOME)"/.local/bin
for name in bin/* ; do \
[ -x "$$name" ] || continue ; \
diff --git a/README.markdown b/README.markdown
index cc784678..6bc5d1f0 100644
--- a/README.markdown
+++ b/README.markdown
@@ -441,6 +441,7 @@ Installed by the `install-bin` target:
privileges.
* `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used to
use Taskwarrior, but found it too complex and buggy.
+* `tot(1df)` adds up a list of integers.
* `try(1df)` repeats a command up to a given number of times until it succeeds,
only printing error output if all three attempts failed. Good for
tolerating blips or temporary failures in `cron(8)` scripts.
diff --git a/bin/tot.awk b/bin/tot.awk
new file mode 100644
index 00000000..c25c718d
--- /dev/null
+++ b/bin/tot.awk
@@ -0,0 +1,3 @@
+# Total a column of integers
+{ tot += $1 }
+END { printf "%u\n", tot }
diff --git a/man/man1/tot.1df b/man/man1/tot.1df
new file mode 100644
index 00000000..c098cbe1
--- /dev/null
+++ b/man/man1/tot.1df
@@ -0,0 +1,19 @@
+.TH TOT 1df "September 2016" "Manual page for tot"
+.SH NAME
+.B tot
+\- print a count of entries in a directory
+.SH SYNOPSIS
+printf '%u\\n' 5 9 53 145 |
+.B tot
+.br
+.B tot
+file
+.br
+.B tot
+file1 file2
+.SH DESCRIPTION
+.B tot
+adds up all the newline-delimited integers given as input, and prints the
+total.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>