In linux, You Can batch modify the IP content in an IP file containing a large amount of data and deduplicate the content.
As an apprentice in linux, I shared my experiences in solving this small problem. I used a small skill to solve this problem and found that linux terminals are very powerful, the following describes the problem in detail and the solution.
Problem description: To analyze logon Ip addresses, there are many log files with different Ip addresses. First, you must combine all log files into one log file, change the last Ip address to 0. For example, if the original IP address is 127.0.0.1, the current Ip address is 127.0.0.0.
Solution: use linux terminal commands
1. Merge multiple log files into one log file:
Cat test1.log test2.log test3.log> test. log
2. test. log contains the Ip addresses of all files. How can I change the last Ip address to 0? The point is that at first I wanted to use a regular expression to modify the Ip address, but I did not get the result, so I used a small trick:
1> Create a New test_middle.log in the current directory to keep the backup.
2> cut-d.-f1, 2, 3 test. log> test_middle.log
3> cat test_middle.log found that the IP address is similar to 127.0.0. I think everyone knows the role of the last shall statement. That's right, it's word segmentation. Take the first three paragraphs and write them to test_middle.log.
4> Add ". 0 ", and then write it to test. log, shall Script: sed's/$ /&. 0/g 'test_middle.log> test. log
Note: There are more than one solution to the problem. If you have a good solution, you may wish to share it with others. While learning, please respect the fruits of others' work. So, reprinted please indicate the source: http://www.cnblogs.com/ForeverLover/p/5085509.html