04 February 2018

Randomized addition worksheets for kiddos using Bash Pipelines

Following up on a prior randomized worksheet for reading, here's a way to generate as many simple addition worksheets as you care to print:

#!/bin/bash
# Print a US letter page of addition problems using numbers 0 through 10.
(
    for i in $(seq 1 26); do
        printf "%2d %s %2d = \n" "$((RANDOM % 11))" "+" "$((RANDOM % 11))"
    done
) \
| column -nxc 36 \
| sed G \
| head -n -1 \
| a2ps -1 --chars-per-line=32 --no-header --borders=no

Subscribe Subscribe to The Return of Agent Zlerich