diff options
author | Erich Eckner <git@eckner.net> | 2019-10-23 10:12:09 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-10-23 10:12:09 +0200 |
commit | 669e9b6b475053946601210e806b3f58c8094c16 (patch) | |
tree | f723f2da512391d808b1462b9411d52876059f81 | |
download | mailarchive-search-669e9b6b475053946601210e806b3f58c8094c16.tar.xz |
initial commit
-rwxr-xr-x | mailarchive-search | 28 |
1 files changed, 28 insertions, 0 deletions
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}" |