Latest web development tutorials

Linux less Command

Linux less Command

Linux command Daquan Linux command Daquan

less and more similar, but uses less free to browse files, and more can only move forward, but can not move backward, but less does not load the entire file before viewing.

grammar

less [参数] 文件 

Parameter Description:

  • -b <buffer size> set the buffer size
  • -e When the file display ends automatically leave
  • -f forced open a special file, such as a peripheral device code, binary files and directories
  • -g flag only last search keywords
  • -i Ignore case when searching
  • -m shows the percentage is similar to the more command
  • -N Display each line number
  • -o <filename> output will be less content saved in the specified file
  • -Q Not use a warning tone
  • -s displays consecutive blank line behavior
  • -S Line too long will discard the excess
  • -x <number> the "tab" key to display a predetermined number of spaces
  • / String: Down search for "strings" function
  • ? String: up search for "strings" function
  • n: Repeat the previous search (and / or related?)
  • N: inverted repeats before a search (and / or related?)
  • b Backward one
  • d turned back half a page
  • h Display help screen
  • Q Quit command less
  • u Scroll half a page forward
  • y Scroll forward one line
  • Spacebar to scroll one line
  • Enter keys to scroll through a
  • [Pagedown]: turning down a
  • [Pageup]: a flip up

Examples

1, View Files

less log2013.log

2, ps to view and process information through less Pagination

ps -ef |less

3, view the command history by using the recording and less Pagination

[root@localhost test]# history | less
22  scp -r tomcat6.0.32 [email protected]:/opt/soft
23  cd ..
24  scp -r web [email protected]:/opt/
25  cd soft
26  ls
……省略……

4, browse multiple files

less log2013.log log2014.log

Explanation:
Input: n, switch to log2014.log
Input: p, switch to log2013.log

Additional Notes

1. Full Screen Navigation

  • ctrl + F - move forward one screen
  • ctrl + B - move backward one screen
  • ctrl + D - to move forward half a screen
  • ctrl + U - move back half a screen

2. The one-way navigation

  • j - move forward line
  • k - move up one row

3. Other navigation

  • G - move to the last row
  • g - move to the first row
  • q / ZZ - exit the less command

4. Other useful commands

  • v - using the configuration editor to edit the current file
  • h - show less help documentation
  • & Pattern - Display only rows that match the pattern, rather than the entire file

5. Mark navigation

When using less to view large files, you can make a mark at any location, you can command to navigate to the location marked with a specific text mark:

  • ma - use of a mark the current position of the text
  • 'A - Navigate to mark a place

Linux command Daquan Linux command Daquan