csci4061/p1-code/table.sh
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

24 lines
427 B
Bash
Executable file

#!/bin/bash
# Generate a table of squares and cubes. Used for testing output
#
# usage: table.sh [limit=30] [sleep=0]
#
# Prints squares/cubes up to limit then sleeps given amount. Both
# params optional.
limit=30
if (($# >= 1)); then
limit=$1
fi
sleeptime=0
if (($# >= 2)); then
sleeptime=$2
fi
for i in `seq $limit`; do
printf "i^1= %6d i^2= %6d i^3= %6d\n" $((i)) $((i*i)) $((i*i*i))
done
sleep $sleeptime