VI operation example

xiaoxiao2021-03-06  78

How to repeat the information in the archive in simple and organized ways, and store these data to the new file without more to schedule, strictly said that such processing homework should be selected like SED , the tool like AWK is better in handling efficiency; if you have simple words, GREP is enough to cope. 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 the time, the network was a bit busy. I used NetStat -ct to read the situation of the network for a while, 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 naturally wake 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, establish 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 .. I woke up by Zhou Jun, I looked at" Powering " "Two words, method finds. # Vi access_log I use the VI instruction to enter the Access_log file to be edited. Because there is no special option, the cursor will be in the first line. Next, I plan to have youth No. 1, the address is 202.102.141.56, all of the visits records all moved to the end of the file. The Directive is as follows: g / 202.102.141.56 / MO $ This line instruction where G represents Global, is the meaning of the entire file. In: g / behind is the string to search, I will enter 202.102.141.56, which is a youth one. Final Mo $ actually the Ex Editor instruction, Mo is moved; $ means the last line meaning Therefore, this line of instructions is that the file contains 202.102.141.56 from top to the next check. If you find the line to move the line to the final line of 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 visiting data of" Youth No.1 ". Of course, I can continue to use the same technique to organize it for youth, II, but my idea is a separate deposit, so this It is not necessary to handle it. Turn it to I want to delete unrelated data.

: /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 to start looking for strings. In this way, I have moved the cursor to the beginning of the "Youth No.1" data. The cursor is the data I don't need, the following is the content that is planning to archive. Then I jump up the cursor back (that is, press the K key), then clear all the data to the first line. The D1G is left behind is the "Youth No.1" all data. : 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 want to have the original data, I will choose: Q! I will give up the archive and exit the VI. But because I still need to continue dialysis "There is data" Youth Second, No. 3 ". So I have to return to the original file data, 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 status of the last store, because I have not saved the original data when I entered VI, then I can use the previous practice to handle "Youth, III" "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 instructions do not support multiple windows editing. So you can't use a VI program to open two files to do data exchange, transfer editing. But this is not too big, because alternative methods are also It is very simple. Just make good use of the VI program, first put the data data of the A file, then continue to edit the B file, then call out. For the operation of the VI program, use D (delete) and Y (Yang) will put the data into the famous buffer. But for this article, I will never choose Delete, although I get it, but it is too dangerous. So the only and correct choice is to use Yank. She Support lowercase letters A ~ Z Named-name buffer for users to operate. Now think about it carefully, it seems that I have never been suspected of 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 24; # vi / "dec 24" Messages cursor will stop in the first information I want. I revealed the same day's record, so I found that the three-line information was strange, I put The cursor stops 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 use the data of IP.

Same first, first stop the cursor at the beginning of the IP, then next command; "W8yw this line means to save 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 buffers. Finally, I call my own anomalous record file, ready to store the data;: E STRANGE2K112 When I am calling, I add the option " ", so my cursor will stop Come on the last line. I started sequentially store the data PUT to STRANGE2K112 in the "QP" WP "EP ..." qp "wp" EP ... "qp" wp "EP .... Copride data after the data; before you want to put it before the cursor Use uppercase p. In the process of editing, the data that has already 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 clear how the VI program handles DELETE data. The VI program plans 9 kinds of buffers for DELETE to do data temporary. 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 buffer 1, and the data within the original buffer 1 is squeezed into the buffer 2 in this class, which can be imagined, the data of the buffer 8 can be imagined. After being squeezed into the buffer 9, the data of the original buffer 9 will be discarded. The data that is discarded will not be saved by the way of calling the name 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 the large call buffer. It is not possible to be large to small. The first buffer of the call can not be started by the buffer 1, which can be other numbers. I personally smaller, age 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 disappears. And dot (.) Is the meaning of Repeat. The effect is equivalent to the data of the next buffer, so the data 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-121873.html

New Post(0)