Print a message at specific line on prompt

Hi Friends,
I am using HP-UNIX(ksh). I want to print a message at specific line on the prompt screen. For Example:

for num in 1 10 3 145
do
echo $num // need to print this on the same line for each number
sleep 2
done

Actual Output:

1
10
3
145

Expected Output:

1 then it will be 10 then 3 and at last 145 (like a electronics stopwatch display)

please suggest me how to do this? can we use tput here?

You can achieve this with tput. Check the man page of tput.

Regards

How about issuing a clear command before echo? would that help?

Thanks Franklin..

But the actual problem here is to get the cursor position dynamically. The cursor pos is variable and this prog need to get the printing position before printing to that location. Other parts like clearing we can use our own logic. Like ..

====================
for e in asd niroj sinu rajesh ava o
do

l=` expr length $e `
tput cup 30 40#This is varible. I need to get the cursor pos dynamically

while [ $l -ge 0 ] //to clear at position i am overwriting with space double the prev word length
do
print " \c"
l=` expr $l - 1 `
done

tput cup 30 40#This is varible. I need to get the cursor pos dynamically

echo $e
sleep 1

done

Maybe ncurses is something for you, Google on it.

Regards

Actually this solution I got from a site..

for num in 1 10 3 145
do
tput sc //Save the current cursor position
echo "$num\c"
tput rc //Recover the saved cursor position
sleep 1
tput el //Clears the current line
tput rc
done

:slight_smile: