开发者

ECHO "Text", sleep 2s, erase "Text", then "ECHO "Text 2", etc

开发者 https://www.devze.com 2023-02-16 03:56 出处:网络
I have a shell script that simply outputs events on a calendar like: Event 1 Monday 10:00PM - 11:00PM Event 2

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消