문제

I want to create a little animation in the stdout of the terminal using printf. So far I figured out how to replace the last line with

#!/bin/csh -f        
printf "text1"
printf "text2"
sleep 1
printf "\r replaced text2"

How do I replace both lines?

printf "\r\r replace text1"

does not work....

도움이 되었습니까?

해결책

You need to use the cuu1 terminfo capability to move the cursor up.

printf "foobar"
tput cuu1
printf "baz"

다른 팁

Ignacios answer brought me on the right track! Thanks!! Nevertheless:

    tput cuu N

sets your cursor N lines back.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top