Saturday 26 October 2019

unix - What commands can I use to reset and clear my terminal?


I have been using the command:


reset

to clear my terminal. Although I am pretty sure this is not what I should be doing. Reset, as the name suggests, resets your entire terminal (changes lots of stuff). Here is what I want:


I basically want to use the command clear. However, if you clear and then scroll up you still get tonnes of stuff from before. In general this is not a problem, but I am looking at gross logs that are long and I want to make sure that I am just viewing the most recent one. I know that I could use more or something like that but I prefer this approach.



Answer



The scrollback buffer is not a feature of bash but of the terminal program. You didn't say what terminal you using.


If you are using xterm you might be able to clear the saved lines by echoing ESC-c to the terminal.


This may or may not work on whatever terminal program you are using.


On linux this will probably work:


echo -e '\0033\0143'

on FreeBSD echo doesn't accept -e so you can try:


printf '\033\143'

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...