Clear half of the screen from the command-line
You could use tput
to move the cursor to a given line in the screen, e.g.,
tput cup 11 0
to move it to the twelfth line (values count from zero).
Along the same lines, you could use tput
to clear from that position to the end of the screen, using the ed
capability. Combining,
tput cup 11 0 && tput ed
might be what was wanted.
If you want to go to the halfway mark on the screen, the first number returned by
stty size
is (on most systems) the number of rows of the screen. Adding that to the command:
tput cup $(stty size|awk '{print int($1/2);}') 0 && tput ed
The clear
program differs from tput ed
:
- it moves the cursor to the home position (upper left) and
- clears from that point to the end of the screen.
Caveat: on some platforms tput ed
may not work due to problems fixed long ago. In those cases, upgrading your curses/ncurses configuration will fix the problem.