#!/bin/bash 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` ; test -z "$EL" && EL=`tput ce` ED=`tput ed` ; test -z "$ED" && 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 -n "$THOME" #eval "$@" |& while IFS='' read line do if [[ -z "${prev_line[$line_no]}" ]] then prev_line[$line_no]="$line" fi if [[ "x$line" = "x${prev_line[$line_no]}" ]] then echo -nE "$NL$EL$line$EL" else echo -nE "$NL$EL$SMSO$line$EL$RMSO" fi NL=" " prev_line[$line_no]="$line" let line_no=line_no+1 done < <(eval "$@") if [[ $line_no -eq 0 ]] then echo -n " ---===${SMSO} No Output ${RMSO}===--- $EL" fi echo -n "$ED" sleep $delay done