summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--retiolum/hosts/ohz10
-rwxr-xr-xservices/lib/filter54
2 files changed, 54 insertions, 10 deletions
diff --git a/retiolum/hosts/ohz b/retiolum/hosts/ohz
deleted file mode 100644
index e452743b..00000000
--- a/retiolum/hosts/ohz
+++ /dev/null
@@ -1,10 +0,0 @@
-Subnet = 10.243.118.171/32
-Subnet = 42:a06d:7412:809a:b74a:8052:daba:c99f/128
------BEGIN RSA PUBLIC KEY-----
-MIIBCgKCAQEA7vZFyHtBC9WbXTKcJ2mXxTsZnZqGrDzP7PVtkaBQfTT6J2Qtct5i
-0klA8yvXHUeVdt+hho7rISX4LJr+RDVdhU4ZgrcyJ3rR3moRGzLUV2VLroc1Mnbs
-kkK1mowNk/jZpf6XyRpGL+NFMCZexmfjTdMaMLhzoRbA6w/ffPSSuDZdbG2F5bMk
-BmF6biPcS9Z652ePXh9ViUUKBpLTHQvgK5/iZjI6ik/eit50jrjO6MapUVP/7qob
-VeXE7Zos3UuHLiKegN68VbFQp4qu7jNH4jRun3Pm/Zd/OaGCREIDnfyIyauDNkaT
-QUEL+h0zsM+t2rLT08Wo/sdNX16iMrs9FwIDAQAB
------END RSA PUBLIC KEY-----
diff --git a/services/lib/filter b/services/lib/filter
new file mode 100755
index 00000000..f69a5b0d
--- /dev/null
+++ b/services/lib/filter
@@ -0,0 +1,54 @@
+#! /bin/sh
+#
+# usage:
+# export PATH="//services/lib:$PATH"
+# cd services
+# ls | filter owner == $LOGNAME | filter hasnt mail
+#
+set -euf
+
+main() {
+ case $# in
+ 2) op1 "$@";;
+ 3) op2 "$@";;
+ *) echo 'You are made of stupid!' >&2; exit 23;;
+ esac
+}
+
+# op1 OP SCHEMA
+op1() {
+ case "$1" in
+ has)
+ xargs grep -H "^$2:" \
+ | cut -d: -f1
+ ;;
+ hasnt)
+ a=$(mktemp)
+ b=$(mktemp)
+ trap "rm $a $b; trap - EXIT INT QUIT" EXIT INT QUIT
+ cat > $a
+ cat $a | xargs grep -H "^$2:" | cut -d: -f1 > $b
+ diff -u $b $a | sed -n '/^++/d;s/^+\(.*\)/\1/p' | grep .
+ esac
+}
+
+# op2 SCHEMA OP RHS
+op2() {
+ case "$2" in
+ ==|is)
+ xargs grep -H "^$1:$3$" \
+ | cut -d: -f1
+ ;;
+ !=|isnt)
+ xargs grep -H "^$1:" \
+ | grep -v ":$1:$3" \
+ | cut -d: -f1
+ ;;
+ contains)
+ xargs grep -H "^$1:.*$3.*$" \
+ | cut -d: -f1
+ ;;
+ esac
+}
+
+main "$@"