Statistics of linux study notes

【Good memory is not as good as bad writing】

I encountered a scenario today. The number of messages received by the downstream test statistics is inconsistent with the number of messages sent to him by the upstream. If the problem occurs, we need to investigate now, but I have given a log file of several hundred megabytes and open it with a text editor such as UE. Statistics feel too cumbersome, so I threw the log file on the server to check, and I feel that statistics are very useful at this time

Premise: Create a welcome.txt file yourself

1. Count the number of occurrences of the character "to" in the statistical file

[imix@localhost example]$ grep -o 'to' welcome.txt |wc -l
10
[imix@localhost example]$ grep -o 'good\|to' welcome.txt |wc -l (statistics good, to appear times)

 2. Open welcome.txt with vi editor and enter the following in command mode

:%s/findStr//gn
[imix@localhost example]$ vi welcome.txt

 

 
 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939778&siteId=291194637