Getting LESS to return back to command line if a short file is displayed

10

1

Is there a command line option that will allow less to return to the command line if there are not sufficient lines in the file to warrant paging.

Sure I have seen it in the past but can't find the option in help.

justintime

Posted 2010-08-12T08:47:10.850

Reputation: 2 651

To summarize the below answer's and comments: less -FX works. It produces a behavior similar to that of more for short files. – loxaxs – 2017-05-29T10:15:55.533

Answers

20

See manpage:

-F or --quit-if-one-screen

Causes less to automatically exit if the entire file can be displayed on the first screen.

sleske

Posted 2010-08-12T08:47:10.850

Reputation: 19 887

2+1 - Goes off and aliases less to less -F – Nifle – 2010-08-12T08:55:53.310

4Not sure I see the point of -F by itself as (at least on my Linux) doesnt display any of the file. But combined with -X it does what I want. Thanks. – justintime – 2010-08-12T15:47:12.497

The different behaviors are explained in this SU question and answer and even more in the blog linked from there.

http://superuser.com/questions/134598/how-can-you-turn-off-alternate-screen-in-osxs-terminal-app

http://fixlog.blogspot.com/2006/09/stop-gnome-terminal-screen-clear.html

– None – 2010-08-13T19:29:30.337