Skip to content

Instantly share code, notes, and snippets.

@Rycieos
Created September 29, 2017 18:21
Show Gist options
  • Save Rycieos/89a334edbd9849ba359ba70fd5517ea8 to your computer and use it in GitHub Desktop.
Save Rycieos/89a334edbd9849ba359ba70fd5517ea8 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Poor man's watch
if [ "$1" = "-n" ]; then
TIME=$2
shift 2
else
TIME=2
fi
while :; do
clear
# Right justify date
printf "%*s\r" "$(tput cols)" "$(date)"
# Print time interval and command to be run
printf "Every %1.1fs: %s\n" "${TIME}" "$*"
$*
sleep $TIME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment