move ~/bin to ~/.local/bin

This commit is contained in:
2025-09-09 12:57:50 +02:00
parent b8cf5a87ab
commit f86008162b
42 changed files with 199 additions and 17 deletions

26
.local/bin/§awk Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
this="${0##*/}"
USAGE="\
usage: $this [<awk_args>] <field_no>
Ex: getent passwd | grep andy | $this -F: 5
Ex: echo \"A B\" | $this 2
"
err(){ echo -e "$USAGE" >&2; exit 1; }
[[ $# -eq 0 ]] && err
# bail if the *last* argument isn't a number (source:
# http://stackoverflow.com/a/808740)
last=${@:(-1)}
if ! [ $last -eq $last ] &>/dev/null; then
echo "_awk! Last argument (awk field) must be numeric." >&2
err
fi
if [ $# -gt 1 ]; then
# Source:
# http://www.cyberciti.biz/faq/linux-unix-bsd-apple-osx-bash-get-last-argument/
rest=${@:1:$(( $# - 1 ))}
else
rest='' # just to be sure
fi
awk $rest "{ print \$$last }"