1

A number of commands (eg watch, less) are able to temporarily clear the tty to display a full screen of information, then when the command exits restore the original tty content.

Is there a way to achieve this in a bash script?

Tom
  • 7,269
  • 1
  • 42
  • 69

1 Answers1

5

Use tput. Here's a minimal example:

#!/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
hnicke
  • 602
  • 4
  • 7