代码之家  ›  专栏  ›  技术社区  ›  Tom

临时清除tty[副本]

  •  0
  • Tom  · 技术社区  · 7 年前

    这个问题已经有了答案:

    许多命令(如 watch 我是说, less 能够暂时清除TTY显示全屏幕的信息,然后当命令退出时恢复原来的TTY内容。

    有没有办法在bash脚本中实现这一点?

    1 回复  |  直到 7 年前
        1
  •  4
  •   hnicke    7 年前

    使用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
    
    推荐文章