使用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
Run Code Online (Sandbox Code Playgroud)