这个问题已经有了答案:
许多命令(如 watch 我是说, less 能够暂时清除TTY显示全屏幕的信息,然后当命令退出时恢复原来的TTY内容。
watch
less
有没有办法在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