From 669e9b6b475053946601210e806b3f58c8094c16 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 23 Oct 2019 10:12:09 +0200 Subject: initial commit --- mailarchive-search | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 mailarchive-search diff --git a/mailarchive-search b/mailarchive-search new file mode 100755 index 0000000..36033fa --- /dev/null +++ b/mailarchive-search @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ $# -ne 1 ] && [ $# -ne 2 ]; then + >&2 printf 'usage: %s url [output-directory]\n' "${0##*/}" + exit 1 +fi + +url="${1%/}/" +if [ $# -eq 1 ]; then + dir=$(mktemp -d) +else + dir="$2" +fi + +curl -L -o "${dir}/#1" "$( + curl -LSs "${url}" \ + | sed ' + s@^.*href="\([0-9]\+-[a-zA-Z]\+\.txt\.gz\)\">.*$@\1@ + t + d + ' \ + | tr '\n' ',' \ + | sed ' + s@^\(.*\),$@'"${url}"'{\1}\n@ + ' +)" + +>&2 printf 'Data resides in %s\n' "${dir}" -- cgit v1.2.3-70-g09d2