Linux common commands-34: less

The less command is used to display the contents of a file or command output. It displays only one page at a time, but allows forward and backward navigation in the file. The command is mainly used to open large files, it does not read the entire file, and the loading time will be faster compared to other text editors.

Syntax format: less [parameter] [file]

Common parameters:

Example

 # 查看文件less test.py # 查看时显示行号less -N test.py # 查看命令历史并通过less分页显示history | less

After entering less , you can use the following commands to navigate

  • Down arrow, carriage return, e , or j , go forward one line
  • Up arrow, y or k , move backward one line
  • space or f to move forward one page
  • b , move backward one page
  • /pattern , search forward for matching patterns
  • ? pattern , search backwards for matching patterns
  • n , repeat the last search
  • N , repeat the last search in reverse
  • g , go to the first line of the file
  • Ng , go to line N in the file
  • G , go to the last line of the file
  • p , go to the beginning
  • h , show help
  • q , quit

This article is reprinted from https://xugaoxiang.com/2022/06/10/linux-cmds-34-less/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.