diff bin/pastelog @ 5643:56dcce63901b

<tswett> revert
author HackBot
date Sun, 21 Jun 2015 02:47:59 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/pastelog	Sun Jun 21 02:47:59 2015 +0000
@@ -0,0 +1,28 @@
+#!/bin/bash
+cd /var/irclogs/_esoteric
+
+pasterandom() {
+    if [ "$1" -gt 150 ]; then
+        echo "No."
+        exit
+    fi
+    for i in $(seq "$1"); do
+        file=$(shuf -en 1 ????-??-??.txt)
+        echo "$file:$(shuf -n 1 $file)"
+    done | paste
+}
+
+if [ "$1" ]; then
+    if expr "$1" + 0 >/dev/null 2>&1; then
+        pasterandom "$1"
+    else
+        lines=$(timeout 25 grep -P -i -- "$1" ????-??-??.txt | head -n 301)
+        {
+            echo "$lines" | head -n 300
+            [ $(echo "$lines" | wc -l) -eq 301 ] && echo "[too many lines; stopping]"
+        } | paste
+    fi
+else
+    pasterandom 40
+fi
+