【发布时间】:2018-07-13 12:17:08
【问题描述】:
许多命令(例如watch、less)可以暂时清除tty以显示全屏信息,然后在命令退出时恢复原始tty内容。
有没有办法在 bash 脚本中实现这一点?
【问题讨论】:
许多命令(例如watch、less)可以暂时清除tty以显示全屏信息,然后在命令退出时恢复原始tty内容。
有没有办法在 bash 脚本中实现这一点?
【问题讨论】:
使用 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
【讨论】: