Operating System - HP-UX
1833875 Members
1981 Online
110063 Solutions
New Discussion

Re: Echo at specific screen position ?

 
Ian McClement_1
Occasional Advisor

Echo at specific screen position ?

Can someone answer me a fairly simple question.
Is it possible to echo (or other command) to a certain screen position (specify row and column) . So as within loop can keep refreshing the character so as to know how many time the loop has executed.
Could clear the screen then echo, but have other info on screen that cannot be cleared.

Cheers
Ian
4 REPLIES 4
Nick Wickens
Respected Contributor

Re: Echo at specific screen position ?

Hi Ian

You need to use "tput cup y x" where y is the row position and x is the column position.

ie

integer n=0
while true
do
tput cup 3 20
clear
echo $n
let n=n+1
sleep 3
done

Hats ? We don't need no stinkin' hats !!
Steven Sim Kok Leong
Honored Contributor

Re: Echo at specific screen position ?

Hi,

You should be looking at something like ncurses:

http://dickey.his.com/ncurses/ncurses.faq.html

Hope this helps. Regards.

Steven Sim Kok Leong
Nick Wickens
Respected Contributor

Re: Echo at specific screen position ?

Hi Ian

Sorry mistake above you need to put the clear statement before the tput statement otherwise it resets the position of the cursor.
Hats ? We don't need no stinkin' hats !!
Steven Sim Kok Leong
Honored Contributor

Re: Echo at specific screen position ?

Hi,

I agree with Nick that tput is a better choice that ncurses.

Hope this helps. Regards.

Steven Sim Kok Leong