#! /bin/bash -f lim=$1 shift cmd=$@ if [[ $lim =~ ^[0-9]+$ ]] then if [ x"$cmd" == "x" ] then echo 'Usage: repeat count command [optional-args]' exit 1 fi else echo 'Usage: repeat count command [optional-args]' exit 1; fi for count in `seq 1 $lim` do $cmd done