#!/bin/bash
# usage: ./repeat.sh <command> [frequency in seconds]
# control+c to quit
COMMAND=$1 # command is first arg
FREQUENCY=${2:-1} # frequency is second arg or "1"
clear
trap ctrl_c INT # catch ctrl+c keypress
function ctrl_c
{
clear
tput cnorm # put the cursor back to normal
exit
}
while [ true ]
do
tput civis # hide the cursor
tput cup 0 0 # put cursor at top-left
$COMMAND # execute the command
sleep $FREQUENCY # wait for frequency
done