summaryrefslogtreecommitdiff
path: root/collect-tos-for-alpine-addressbook
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-11-13 14:13:47 +0100
committerErich Eckner <git@eckner.net>2021-11-13 14:13:47 +0100
commit26184588b092df470da2961898025252f4f5a4a7 (patch)
tree3891c94c1a73aecee4f46e79bc2a4777f6a8c9c4 /collect-tos-for-alpine-addressbook
parent21a0006689c798cc9a4faa9179bd8f14d3169f37 (diff)
downloadsammleEmails-26184588b092df470da2961898025252f4f5a4a7.tar.xz
collect-tos-for-alpine-addressbook new
Diffstat (limited to 'collect-tos-for-alpine-addressbook')
-rwxr-xr-xcollect-tos-for-alpine-addressbook41
1 files changed, 41 insertions, 0 deletions
diff --git a/collect-tos-for-alpine-addressbook b/collect-tos-for-alpine-addressbook
new file mode 100755
index 0000000..937642c
--- /dev/null
+++ b/collect-tos-for-alpine-addressbook
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+sed '
+ :a
+ N
+ s/\n\s\+/ /
+ ta
+ P
+ D
+' tmp/header \
+| sed -n '
+ s@^\(bcc\|Bcc\|BCC\|cc\|Cc\|CC\|To\|Reply-To\): @@
+ T
+ :b
+ s@^\(\([^"]*"[^"]*"\)*[^"]*\),\s\+@\1\n@g
+ tb
+ p
+' \
+| sed '
+ s#^\(.*\S\)\s*<\(\S\+@\S\+\)>$#\2 \1#
+ t
+ /^\S\+@\S\+$/!d
+' \
+| sort -uf \
+| while read -r email comment; do
+ printf '%s %s %s\n' \
+ "${#comment}" \
+ "$(echo "$comment" | base64 -w0)" \
+ "${email}"
+done \
+| sort -k3,3 -k1nr,1 \
+| uniq -f2 \
+| while read -r _ comment email; do
+ printf '\t%s\t%s\n' \
+ "$(
+ printf '%s\n' "${comment}" \
+ | base64 -d \
+ | sed 's@^\(["'"'"']\)\(.*\)\1@\2@'
+ )" \
+ "${email}"
+done