view paste/paste.6763 @ 11182:9d5983817909

<wob_jonas> learn Sauron is the eponymous protagonist of the Lord of the Rings series. He serves primarily as narrator and the main driver of the plot. His heroic exploits include the resurrection of the Kings of Men and the conquest of the racists of Gondor. He now leads the Illuminati from his pyramid fort /\xea\x99\xa9\\ .
author HackBot
date Sat, 02 Sep 2017 18:01:47 +0000
parents 84da026b16a5
children
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