8 repeat - Run a give command repeatedly
12 repeat I<COMMAND> [I<ARGS>]
20 How many times to repeat the given command.
21 Default is -1 which means infinite.
25 How many times the command has been ran.
26 It is not a variable repeat(1) itself takes as input,
27 but passes to I<COMMAND> for its information.
31 Stop repeat(1) if I<COMMAND> exists with this return code.
32 By default the return code is not checked.
36 Sleep interval between invocations.
37 In seconds, by default.
38 See sleep(1) for valid parameters, eg. "10m" for 10 minutes.
48 .
/usr
/lib
/tool
/bash-utils
50 if [ "$1" = --help -o $# = 0 ]
52 echo "Usage: [REPEAT_TIMES=num] [REPEAT_DELAY=interval] [REPEAT_UNTIL=code] repeat <COMMAND> [<ARGS>]"
56 REPEAT_TIMES
=${REPEAT_TIMES:--1}
60 while [ $REPEAT_TIMES = -1 -o $REPEAT_COUNT -lt $REPEAT_TIMES ]
63 if [ $?
= "$REPEAT_UNTIL" ]
67 REPEAT_COUNT
=$
[REPEAT_COUNT
+ 1]
68 sleep ${REPEAT_DELAY:-0}