Ubuntu – How to keep the screen contents after quitting less or more

command linelessscreen

After exiting from less or more, the screen contents are returned to what they were before. This happens with pagers like less/more, and some other commands. Sometimes it is necessary to keep the contents of the screen after one exits the command.

How can I make it so the text shown immediately before quitting the a program remains visible in the terminal afterwards?

Best Answer

You can use the -X switch:

-X or --no-init
          Disables  sending  the  termcap  initialization and deinitialization strings to the terminal.
          This is sometimes desirable if the deinitialization string does something  unnecessary,  like
          clearing the screen.

Or you could do the following:
For example cat myfile to display the entire file or cat myfile | grep searchterm if you want to search for something specific.

You also could use head -n X or tail-n X to display the first/last X lines of a file.