许多命令(例如watch
,less
)能够临时清除tty以显示全屏信息,然后在命令退出时恢复原始tty内容。
有没有一种方法可以在bash脚本中实现?
答案 0 :(得分:4)
使用tput。这是一个最小的示例:
#!/bin/bash
tput smcup # save the screen
clear # clear the screen
echo this is some text on a blank screen
echo press any button to exit..
read -n1
tput rmcup # reset the screen