view bin/pastelog @ 7429:c4e492dfdb0e

<b_jonas> slashlearn sugar/Sugar, spice, and everything nice. These were the ingredients chosen to create the perfect little girl. But Professor Utonium accidentally added an extra ingredient to the concoction: Chemical X! Thus the Powerpuff Girls were born! Using their ultra super powers, Blossom, Bubbles, and Buttercup have dedicated their lives to fighting crime and the forces of evil!
author HackBot
date Sun, 17 Apr 2016 21:23:45 +0000
parents 56dcce63901b
children
line wrap: on
line source

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