Created
September 8, 2011 11:45
-
-
Save bonifaido/1203220 to your computer and use it in GitHub Desktop.
Watch for Solaris
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo "usage: `basename $0` [-n secs] command" | |
} | |
if [ $# -eq 0 ] | |
then | |
usage | |
exit 1 | |
fi | |
seconds=2 | |
while getopts "n:" opt | |
do | |
case $opt in | |
n) | |
seconds=$OPTARG | |
shift $(($OPTIND - 1)) | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac | |
done | |
command=$1 | |
while [ 1 ] | |
do | |
res=$(eval $command) | |
time=$(date "+%a %b %e %T %Y") | |
cols=$(tput cols) | |
part=$(printf "Every %ss: %s " "$seconds" "$command") | |
just=$(($cols - ${#part})) | |
clear | |
printf "%s%*s\n\n%s\n" "$part" $just "$time" "$res" | |
sleep $seconds | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment