![](https://seccdn.libravatar.org/avatar/27aacf61a13c66fcc083fcf8a84823bc.jpg?s=120&d=mm&r=g)
Roger Oberholtzer wrote:
On Mar 29, 2009, at 10:21 AM, David C. Rankin wrote:
Listmates,
In BASH, how can I make the output of several commands all start from the same spot on the screen? In c we used to have all these nice libraries that gave control over X,Y screen output. (IIRC we were actually manipulating the video buffer) But in bash, there doesn't seem to be any way to do this.
For example, if I have a simple counter and I want to see the numbers increasing without scrolling a line for every number output, I ended up having to do this (just paste it into the command line):
echo -en "\n\tThe count stands at: "; for ((i=1;i<=120;i++)); do mstrlen=${#i}; echo -en "$i"; sleep .1; for ((j=0;j<$mstrlen;j++)); do echo -en "\b"; done; done; echo -e "\n"
Surely there is an easier way. What say the bash gurus??
You need tput. Works on just about any terminal, including the one emulated in konsole/xterm/whatever.
Roger Oberholtzer
Per, Roger, That's exactly what I needed. Somebody to point me to the escape sequences, (and I bet after tearing tput apart -- back to the escape sequences), so my quick scripts can take on a whole new level of form. Thanks. I'm sure you'll see some of the stray fragments of my use(ful|less) scripts shortly. Throw this on the command line ;-) let myx=1 myy=1 myup=1 myright=1; mystr="David Rankin ($myx,$myy,$myup,$myright)"; while :; do echo -en "\033[${myx};${myy}H\033[1;31m${mystr}\033[0m"; [[ $myx -eq $(($COLUMNS-${#mystr})) ]] && myright=0; [[ $myx -eq 1 ]] && myright=1; if [[ $myright -eq 1 ]]; then ((myx+=1)); else ((myx-=1)); fi; [[ $myy -eq $LINES ]] && myup=0; [[ $myy -eq 1 ]] && myup=1; if [[ $myup -eq 1 ]]; then ((myy+=1)); else ((myy-=1)); fi; mystr="David Rankin ($myx,$myy,$myup,$myright)"; sleep .5; done It crawls across the bottom for a second before bouncing, but I'll get to that later;-) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org