view bin/pastelog @ 2648:732f7cec564a

<kmc> addquote <kmc> i had a dream just now where i was in a gymnasium and they had fire alarm pull stations but they also had a similarly shaped "call/cc alarm" which I think you were supposed to pull if you found a way to write call/cc (it was expected that people in this gymnasium would be doing a lot of programming in total dependently-typed languages)
author HackBot
date Sat, 13 Apr 2013 15:18:33 +0000
parents f2f65a1fa363
children f4a2725a0dcb
line wrap: on
line source

#!/bin/sh
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