I\'m trying to create an update-able progress status. In order to do that, I need to be able to clear the last output in its entirety so that I can update it. Carriage retur
Yes, but it is not easy.
Your first and best options is ANSI Escape sequences and you can control cursor by this codes.
For compatibility of your script with everyone else's Terminal you should calculate the width / height of that Terminal.
Here using Xwininfow
you can check yours
wininfo | egrep -e Wid+ -e H+ -e A+
and the output for me will be:
Absolute upper-left X: 0
Absolute upper-left Y: 45
Width: 1600
Height: 855
Then in your script based on width / height you should update the cursor position or clear unused text on Terminal.
As user1934428 commented we have a better option by enabling two global variables using shopt
(= shell options)
>>> shopt | grep win
checkwinsize on
it is on so we can use them
>> echo $LINES
56
>> echo $COLUMNS
228
NOTE that such a task by python is much easier to do than using bash