I have a shell script that simply outputs events on a calendar like:
Event 1
Monday 10:00PM - 11:00PM
Event 2
Monday 11:00PM - 11:30PM
I would like 开发者_开发问答the output to display one event at a time, then wait 2 seconds and replace the first event with the second - then loop back to the 1st. Is this possible?
Do you mean something like that?
while true;
do echo -en "\rText 1"
sleep 2
echo -en "\rText 2"
sleep 2
done
Replacing means going back and overwriting it. Not all terminals support this. But you may experiment with tput
. Look for tput cup
to position the cursor.
精彩评论