In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly analyzes the relevant knowledge of the use of less, a text processing tool in Linux system, which is detailed and easy to understand, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what is the use of less, a text processing tool in the Linux system?"
Although cat can view the contents of a file, it has many limitations, and the less command is the preferred tool if you want to view a large file.
The use of less command less command is an interactive software, so the command parameter options of less include startup parameter options and interactive options, startup parameter options control the pre-run behavior of the software, and interactive parameter options control the behavior after startup.
Less command format less command basic command format is
Less [options] filename1,filename2...less command parameter options on startup parameter options
-b specify the size of the buffer
-e automatically leave when the file is displayed
-f force the opening of special files, such as peripheral codes, directories, and binaries
-g marks only the last keyword searched
-I ignore the case of the search
-m displays the percentage similar to the more command
-N displays the line number of each line
-o Save the less output in the specified file
-Q does not use warning tones
-s displays a row of continuous empty behavior
-S line will be discarded if it takes too long
-x displays the "tab" key as a specified number space
Interactive parameter options
View help within the command
H displays the help interface
Q exits the less command
Search function
/ string: the ability to search down for "string"
? Strings: the ability to search up for "strings"
N: repeat the previous search, if it is /, continue to search down, if so? If so, search up.
N: reverse repeat the previous search, if it is /, it is to continue the upward search, if so? If so, search down.
& string: displays only the lines on the match
Turn the page
B turn up one page
D turn down half a page
U scroll up half a page
Y scroll up one line
The spacebar goes down one line
Enter to the next page
[pagedown]: turn a page down
[pageup]: turn a page up
Ctrl + F: turn the page down
Ctrl + B: turn the page up
Ctrl + D: move half the screen down
Ctrl + U: move half the screen up
G: move to the last line
G: move to the first line Note: down: go down to the place with a large page number
Multiple file openings and inter-file operations the file names of the current file and the next file are displayed below the less
The way to open multiple files
Less file1 file2 file3... You can open multiple files
: e: have run the less command, want to open another file, you can use: e to open, support tab completion, support glob wildcard vim also have the same two ways, already running vim need to use: open file_name, this is not as good as less, 1. Tab key completion is not supported; 2. Glob wildcard is not supported
Switch between multiple files
Type: n: switch to the next file, which is the same as vim (vim uses: bn)
Type: P: switch to the previous file, which is the same as vim (vim uses: bp)
Use less to edit the file v: on the running less interface, using the v option, the system's default editor will be called (generally vi, but how to view it is still a problem? EDITOR and VISUAL may be useful, but the query shows no value, and then there is set-o, the vi off in set-o on the machine. When you type v, you really use it in the same way as vi. You can enter I into INSERT mode and use commands such as QQ _ quote and QW.
Set label
Set the tag, type m in the less interface, and then the word mark appears on the page, and when you enter it as a character (not even multiple characters and numbers), the word mark on the page disappears.
Return to the label, type'in the less interface, and the page appears with the word "goto mark". Enter the label you just set and return to the page you just set. This function is very useful in large file viewing!
The less command uses the instance $ps-ef | less UID PID PPID C STIME TTY TIME CMD root 1 00 May08? 00:00:03 / sbin/init root 200 May08? 00:00:00 [kthreadd] root 3 20 May08? 00:00:03 [migration/0] root 4 20 May08? 00: 00:13 [ksoftirqd/0] root 5 20 May08? 00:00:00 [stopper/0]: # so you can slowly check the id number of each process This is not often used, after all, there is not much need to browse all processes, mainly to meet the need for a single screen to hold all the content, and the need to turn the page back and forth. Some people on the network say that using the F option in the interactive command can reach the end of the file, but experimentally, it can be, but less will have a process of calculating the number of lines of the file. My experimental data is 1221049 lines, and the virtual machine of my personal laptop takes about 10 seconds to the end of the file, which looks good. But tail-f file_name is out of seconds. In addition, if you use F to enter "Waiting for data …" After this mode, use Ctrl + c to exit, will not immediately exit less, you can continue to do other operations G: you can directly jump to the end of the file, neither F nor G takes up so much resources on the system (the amount of experimental data is 308m, but considering that the machine itself is not so good, so the performance of less is quite good). On the same machine, I use vim to open the file. The wa% equivalents under top have a certain soaring phenomenon.
On the "Linux system text processing tool less what is the use of" this is introduced here, more related content can search previous articles, hope to help you answer questions, please support the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.