#!/bin/ksh arg0=`basename $0` USAGE="Usage: $arg0 [-h] [-d delay_secs] command_string" usage() { echo "$USAGE" >&2 exit 1 } help() { echo "$USAGE" echo "Options:" echo " -h Display this help" echo " -d Time to delay between running the command" echo " -n No Bolding" exit } delay=2 bolding=yes while getopts "d:hn" opt do case "$opt" in d) delay=$OPTARG ;; n) bolding='' ;; h) help ;; *) usage ;; esac done let SHIFT=OPTIND-1 shift $SHIFT EL=`tput el || tput ce` ED=`tput ed || tput cd` THOME=`tput home` if [ "$bolding" = yes ] then SMSO=`tput smso` RMSO=`tput rmso` else SMSO='' RMSO='' fi tput clear while true do line_no=0 NL="$THOME" echo "$THOME\c" eval "$@" |& while IFS='' read -p line do if [ -z "${prev_line[$line_no]}" ] then prev_line[$line_no]="$line" fi if [ "x$line" = "x${prev_line[$line_no]}" ] then print -nr "$NL$EL$line$EL" else print -nr "$NL$EL$SMSO$line$EL$RMSO" fi NL=" " prev_line[$line_no]="$line" let line_no=line_no+1 done if [ $line_no -eq 0 ] then echo " ---===${SMSO} No Output ${RMSO}===--- $EL\c" fi echo "$ED\c" sleep $delay done