[转] VI directive detailed explanation

xiaoxiao2021-03-06  105

Transfer] VI directive detailed

How to repeat the information in the archive in simple and organized ways, and store these information into the new file in the case where the original file is not more scheduled? Strictly said that such processing homework should choose SED, The tool like AWK is better in handling efficiency; if it is handled, GREP is enough to deal with. But that choice, usually in the processing process is quite mature, and it is necessary to repeatedly use it, the tool selection. Using VI is a more elastic choice before the suddenness and the mode is not clamped. I made an explanation with an HTTPD Access_Log. 2001/12/16 In the early hours of the morning, I just did something test on the host. At that time, the network was a bit busy. I used NetStat -ct to read the situation of the Internet, and I know that there are several visitors at HTTPD. I wanted to see what they came, so I used VI to see Apache's Access_log, accidentally found that at the same time, my compatriots 202.102.141.56 are scanning the host's httpd server. After observing the NetStat -ct message, I found that she was not completely completed. I want to break the work of people. At that time, people were a bit sleepy, so I took out Vi and quickly continued to be my business. Soon, Zhou Gong's old man will come to grabbiz me to go to the Tolerance, and be his recently operated Playboy website. Virtual real-world European, ministers, and non-eighteen years old! I only have the hard work, no qualification to join. I woke up in the next day, open the computer, first come back to Queen's We are the champions plus a cup of coffee. I suddenly remembered that I haven't finished in the morning, and I will then view Access_log again with VI.乖! Not one, a total of three young people in front of the Internet. At this point in Vi mode, I want to separate three data from the Access_log file, and build three individual files. This idea, I have never thought of it! I am in a time, I don't know what to do? Pick up the pen, write it on the paper. "How to" move "these words. After drinking my coffee, kneel on the table Xiaomi. Only, I woke up by Zhou Gong, I looked at" moving " Two words, the method found. # Vi access_log I use the VI instruction to enter the Access_log file to edit. Because there is no special option, the cursor will be in the first line. Next, I plan to be a youth No. 202.102.141.56, all of the annoying records are all moved to the end of the file. The instructions are as follows:: g / 202.102.141.56 / MO $ This line instruction where G behaves Global, is the meaning of the entire file. In: g / back is the string to search, I will enter 202.102.141.56, which is a youth one. Finally Mo $ is actually an Ex Editor directive, MO is Move movement; $ means the last line meaning Therefore, this line instruction is to check each line of 202.102.141.56 from top to bottom, and find the last line of moving the line to the file. After the execution is completed, the cursor will stay in the last line. I have reached the purpose of dialysis of "There is a visit to youth". Of course, I can continue to use the same way to organize it for youth, third, but my thoughts are separately filed, so at this time It is not necessary to handle it. Tight it is to delete unrelated information.

: /202.102.141.56 Because the cursor has been in the last line, the search will automatically jump back to the first line of weight and start looking for strings. In this way, I have moved the cursor to the beginning of the "Youth No.1". The cursor is the information I don't need, the following is the content that is planning to archive. Then I jumped the cursor to the row (that is, press the K key), then clear the line to the first line of information. The D1G is left behind is "there is a full information for youth". : w TIMMY-NO1 Saves the existing result to the new file, and the file is called TIMMY-NO1. (Timmy word, from Aisimov and Xiwuberg, an undergraduate fiction, is a very special protagonist) here, things count to a paragraph. Because I still want the original information, in the general situation, I will choose: q! Give up the archive and exit VI. But because I still need to continue dialysis "There is" Youth Second, No. 3 "information. So I have to return to the original file, simply as follows: E! This action, I personally prefer called" rewind ". Good After the line is finished, the content of the file will reply to the state of the last archive, because I haven't saved the original information, and then I can use the previous practice to deal with "Youth, II. "Finally, I finally remember: Q! Exit VI. After you finish this, I met the way to sleep back. Dream, Zhou Gong said to me: Don't forget to sleep. After waking up, give me the information, e-mail. I will enjoy the taste of "virtual real-world". Now, since the day, it will work overtime, build a web page ..... Not going! Traditional VI directive, do not support multi-emphasis on the window editor. So you can't use a VI program to open two files to do data exchange, transfer editing. But this is not too inconvenient, because the alternative method is also It is very simple. Just use the VI program to store the information of the A file first, then continue to edit the B file, then call it out. For the operation of the VI, use D (delete) and Y (Yang) will put the information in the famous buffer. But for the needs of this article, I will never choose Delete, although I do, but it is too dangerous. So the only and correct choice is to use Yang. She. Support lowercase letters A ~ Z Named the name buffer for the user to operate. Now think about it, it seems that I never suspected 26 not enough? But she is a fairly limited restriction. Next is an example of my actual operation Everyday system Message file, there will always be some unusual information. Although these messages have regular regularity, there will be unable to master the situation. Since my system service is very simple, I am used to using the VI to see the daily occurrence Things. In the process of review, if there is a different or you don't know clearly, I will first store her in a nameless buffer. After all the inspection is completed, I decide how to deal with it. Now, suppose I want to start reviewing Messages files. There is a record on December 24th; # vi / "dec 24" Messages cursor will stop in the first information I want. I review the same day's record, soon I found that the three-line information has been different, I put The cursor is parked in the first line. The next instruction first puts them in the name buffer; "Q3yy is so, the three-line data will be stored in the Q buffer. Review down and find that the uniform exception of zeroat is related to an IP. So I will ip the information.

Same first, stop the cursor at the beginning of the IP, then next instruction; "W8yw this line means that 8" words "(word) save to the W buffer .xxx.xxx.xxx.xxx is IP The fixed format, where the DOT is defined as a special symbol, depending on a "word", so the format like IP is in the name of 8 "words" (Word). I found it down, I They all have different buffers in different ways. Finally, I call my own anomalous record file and prepare to store the information;: E STRANGE2K112 When I call, I add the option " ", so my cursor will stop Come on the last line. I started sequentially store the information PUT to STRANGE2K112 in the name buffer; "QP" WP "EP .... Capture P will put the information after the cursor; want to put it before the cursor Use uppercase p. During editing, the information that has been deleted, suddenly wants to find it again. This kind of thing is inevitably happening. Some people will choose all the way Undo to go back, even completely give up all the edits, I don't think this is a good practice. So if possible, I still want to find it back, if I find it back. To do this, you must first be clear, the VI program handles the data of Delete. The VI program planned 9 types of buffers for delete to do data temporary storage. The name of the buffer is numbers 1 to 9. The data stores "advanced first out" mode is stored. That is, you clear a data, it will be placed in a buffer 1. The information in the original buffer 1 will be squeezed into the buffer 2 in the original data. In this type, you can imagine, the data of the buffer 8 is squeezed into the data After the buffer 9, the information originally buffered 9 will be discarded. And the discarded information will not be saved in the way the call is called a buffer. After you clear the way it works, you will find that it is necessary to clearly master the information in which buffer area is, it is a difficult thing! The reason is clear, who will remember this code? Even if someone deliberately remembers, it is not a relaxed thing. Frank, kill me, I will not remember! Therefore, things happen, I want to use this method to find it back, my heart must have a few, only nine buffers, can it be still? If possible, use it. When you use, the method of the earth-making steel is, from the call buffer 9, 8, 7 ... all the way, "9P" 8P "7P" 6P "5P" 4P "3P" 2P "1P is of course, the order is also It can be reversed! But the method is really unique. If someone is next to it, it is possible to cause the first English name to be destroyed once. So when doing this, you have to use a better look. First, let me explain, This method is made by the number smaller to a large call buffer. It cannot be large to small. The first buffer of the call can not be started by the buffer 1, can be other numbers. I personally smaller, aged It is also relatively large, so I am used to starting with my head, "of course, there is still no doubt that I have no doubt. Then, u. Type U is undo meaning, the data of the buffer 1 on the screen will disappear. And dot (.) Is the meaning of Repeat. The effect is equivalent to the information of the next buffer, so the information of the buffer 2 will be displayed. If you want to look at the next buffer, you can play U. You can.

转载请注明原文地址:https://www.9cbs.com/read-124590.html

New Post(0)