Linux cmd tips – better less

1, Exit but leave content on screen

i often use less, but that’s horrible when you do exit and then

you will see only terminal without the content.

I found in manual function:

-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 clear‐
ing the screen.

great function, now you can read text file and after exit (q button) you

can see the content of text file.

example:

less -X test.txt

That’s fine, you can do some alias for “less -X”, but when are you connected in new

server then is your new function of less out. So, what will we do with this? :-)

Just easy use your .bashrc or .bash_profile config file and put into this file:

export LESS=X

and then you have perfect less cmd ;-)

2, read your file with less and edit at the moment

In the manual you can find function:

v  —   Invokes  an editor to edit the current file being viewed.  The editor is taken from the environment variable VISUAL if defined, or EDITOR if VISUAL is not defined, or defaults to “vi” if neither VISUAL nor EDITOR is defined.  See also the discussion of LESSEDIT under  the  section    on PROMPTS below.

Example:

read your file with less command and if you want edit this file just press “v”.

If you know more tips for less, tell me this please in discussion…

Leave a Reply