commit 0fb5f2c36bad79a167a258b50af9f331a7af1436 (patch)
parent f0ea71ef0ac89bb37c9162ae8d388002b7b30d98
Author: Alex Karle <alex@karle.co>
Date: Sun, 8 Dec 2019 23:38:38 -0500
bin: a new binginning
I used to use 'bin' for my setup scripts, so its history will
undoubtably be confusing. However, I've recently (through reading The
UNIX Programming Environment) become a fan of putting individual scripts
in ~/bin, so I now wish to version control it.
To start out, we have 'csum', a basic column-sum via awk .
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/bash/bashrc b/bash/bashrc
@@ -22,6 +22,9 @@ PROMPT_COMMAND="echo; history -a"
# Other Settings
shopt -s checkwinsize # check win size after each cmd, update if needed
+# Put ~/bin on the path to facilitate personal customizations
+export PATH=$HOME/bin:$PATH
+
# Custom find function
function ff {
find . -name "*$1*"
diff --git a/bin/csum b/bin/csum
@@ -0,0 +1,11 @@
+#!/bin/sh
+# csum -- sum a column
+if [ -z "$1" ]; then
+ echo "usage: csum N [files]" >&2
+ exit 1
+fi
+
+awk '
+{ s += $'$1' }
+END { print s }
+'