less text viewer

The less program displays the content of a file one screen at a time. You can navigate the file, move to a specific line, and search the file.

Here is an example file opened in less:

linux less program

On the bottom you can see the message: sample_text lines 1-23/37 63%. This message indicates that you’re viewing lines 1 to 23 of the file which has 37 lines, and that you’re viewing 63% of the file.

Here is a list of navigation commands used in less:

  • page down. space, f – one screen forward
  • page up, b – one screen backward
  • up arrow key – up a line
  • down arrow key – down a line
  • / – searches the content
  • g NUMBER – moves to the specified line
  • q – quits the program

 

The man command uses less to display information.

 

Geek University 2022