From dffc965ac8786208e89be50c026e6916433d45f6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius <nico@nico-notebook.schottelius.org> Date: Fri, 27 Aug 2021 18:32:22 +0200 Subject: [PATCH] ++stva --- stva.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 stva.sh diff --git a/stva.sh b/stva.sh new file mode 100755 index 0000000..abe5535 --- /dev/null +++ b/stva.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +i=1 + +new_data="yes" +data="" + +newfile=~/.stva-new +oldfile=~/.stva-cur + +while [ "$new_data" ]; do + new_data=$(curl -Ls https://e-schild.stva.gl.ch/?page=${i} | \ + grep '<td>GL' | sed 's/.*<td>GL //') + + if [ "$new_data" ]; then + data="$data $new_data" + i=$((i+1)) + fi +done + +( + for num in $data; do + echo "GL${num}" + done +) > "$newfile" + +# Ensure old file exists +touch "$oldfile" + +diff -u "$oldfile" "$newfile" +mv "$newfile" "$oldfile"