YouTip LogoYouTip

Linux Comm Less

# Linux less Command [![Image 3: Linux Command Reference](#) Linux Command Reference](#) `less` is similar to `more`. `less` allows you to browse files freely, supports page turning and searching, and supports scrolling up and down. ### Syntax less file **Parameter Description**: * -b Set the buffer size * -e Automatically exit when the end of the file is reached * -f Force open special files, such as peripheral device codes, directories, and binary files * -g Only highlight the last searched keyword * -i Ignore case during search * -m Display percentage similar to the more command * -N Display line numbers for each line * -o Save the output of less to the specified file * -Q Do not use warning sounds * -s Treat consecutive blank lines as a single line * -S Truncate long lines instead of wrapping * -x Display "tab" as the specified number of spaces * /string: Search downwards for "string" * ?string: Search upwards for "string" * n: Repeat the previous search (related to / or ?) * N: Repeat the previous search in reverse direction (related to / or ?) * b Scroll up one page * d Scroll back half a page * h Display help interface * Q Exit the less command * u Scroll forward half a page * y Scroll forward one line * Spacebar Scroll one page * Enter Scroll one line * : Scroll down one page * : Scroll up one page ### Examples 1. View a file less log2013.log 2. Use ps to view process information and display it paginated through less ps -ef |less 3. View command history and display it paginated through less [root@localhost test]# history | less 22 scp -r tomcat6.0.32 root@192.168.120.203:/opt/soft 23 cd ..24 scp -r web root@192.168.120.203:/opt/25 cd soft 26 ls ……omitted…… 4. Browse multiple files less log2013.log log2014.log Description: After typing :n, switch to log2014.log After typing :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 - Move forward half a screen * ctrl + U - Move backward half a screen 2. Single-line Navigation * j - Next line * k - Previous line 3. Other Navigation * G - Move to the last line * g - Move to the first line * q / ZZ - Exit the less command 4. Other Useful Commands * v - Edit the current file using the configured editor * h - Display less's help documentation * &pattern - Display only lines matching the pattern, not the entire file 5. Mark Navigation When using less to view large files, you can mark any position and navigate to the marked text position via commands: * ma - Mark the current position with a * 'a - Navigate to mark a [![Image 4: Linux Command Reference](#) Linux Command Reference](#)
← Linux Comm LocateLinux Comm Ln β†’