#!/bin/sh - # # Print a sequence of numbers, separated by newlines. # See the usage message below for details. # Works on FreeBSD. Does not work on Solaris. # # This script is in the public domain. # Use freely. No warranty. # Usage() { echo "Usage: ${0##*/} [ []]" >&2 echo "Print a sequence of numbers from to (inclusive)," >&2 echo "separated by newlines, using a minimum of digits for" >&2 echo "each number (zero-padded if necessary)." >&2 echo "The default for is 1. The default for is the" >&2 echo "number of digits of ." >&2 exit 1 } if [ $# -lt 1 -o $# -gt 3 ]; then Usage fi GetNum() { case "$1" in *[^0-9]*|"") Usage ;; esac echo "$1" } N_LAST=$(GetNum "$1") if [ $# -gt 1 ]; then N_FIRST=$(GetNum "$2") else N_FIRST=1 fi if [ $# -gt 2 ]; then N_DIGITS=$(GetNum "$3") else N_DIGITS=${#N_LAST} fi exec jot -w "%0${N_DIGITS}d " - $N_FIRST $N_LAST #--