view bin/pastelog @ 2012:c4f83ae4e77e

<olsner> addquote <fungot> but when she saw him fnord and fnord. and then there\'s the fnord, as well as fnord reading sauce with fish, or fnord, that alice quite fnord for it hadn\'t spoken before.
author HackBot
date Tue, 05 Feb 2013 23:27:58 +0000
parents e037173e0012
children 5c453217583b
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=$(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