I want to clear specific part of the screen. Say for example , i am running a bash script
for i in {1..100}
do
echo "Current Record = $i"
done
if i use a clear command over there , it will clear my screen however when i scroll up i would have the old records , is there anyway in unix to just clear a single line everytime
You could use this function where 'char="lots of spaces as required"', and, vert and horiz are the rows and columns of the terminal window where you want to over _write_...
You can overwrite the same line every time by printing a carriage return instead of a newline, the cursor will return to the beginning of the line but not travel down to the next line.
Note this does not clear the line per se, you would need to print blank spaces or use an escape sequence.
printf "Wait for it\r"
sleep 5
printf "Ding! \r"
Things like setting up a scrolling region inside your terminal will also prevent scrollback but are not compatible with all terminals.