临时清除tty

时间:2018-07-13 12:17:08

标签: linux bash scripting tty

许多命令(例如watchless)能够临时清除tty以显示全屏信息,然后在命令退出时恢复原始tty内容。

有没有一种方法可以在bash脚本中实现?

1 个答案:

答案 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