From 9c212606ea3a568ff5d5e0c94fd294fa35aeb853 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 22 Jul 2023 09:07:50 +0200 Subject: show archaic log, if nothing happened recently - do not only consider the last 4 days --- show-irc-log | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/show-irc-log b/show-irc-log index 8ba667c..0986b21 100755 --- a/show-irc-log +++ b/show-irc-log @@ -9,20 +9,35 @@ curl -Ss 'https://mirror.archlinux32.org/irc-logs/%23archlinux32/' \ t d ' \ -| sort \ -| tail -n4 \ -| while read -r s; do - curl -Ss 'https://mirror.archlinux32.org/irc-logs/%23archlinux32/'"${s}"'.html' \ - | sed -n ' - s|^.* <\([^&]\+\)>|\1 \|| - t ok - s|^.* \* \(\S\+\) \(.*\).*$|\1 : \2| - t ok - T - :ok - p - ' - done \ +| sort -r \ +| { + lines_count=0 + while read -r s; do + lines=$( + curl -Ss 'https://mirror.archlinux32.org/irc-logs/%23archlinux32/'"${s}"'.html' \ + | sed -n ' + s|^.* <\([^&]\+\)>|\1 \|| + t ok + s|^.* \* \(\S\+\) \(.*\).*$|\1 : \2| + t ok + T + :ok + p + ' \ + | tac + ) + if [ -z "${lines}" ]; then + continue; + fi + lines_count=$((lines_count + $(printf '%s\n' "${lines}" | wc -l))) + printf '%s\n' "${lines}" + if [ "${lines_count}" -ge 30 ]; then + cat >/dev/null + break + fi + done +} \ +| tac \ | tail -n30 \ > "${tmp_dir}/input" -- cgit v1.2.3-54-g00ecf