repeat.sh. like tail-f, but for commands
#!/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
Written by Dean Rather
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#bash
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#