grep is used to view logs

grep under Linux displays multiple lines of information

grep under standard unix/linux controls the context through the following parameters

 

grep -C 5 foo file displays the line in the file that matches the foo string and the upper and lower 5 lines

grep -B 5 foo file displays foo and the first 5 lines

grep -A 5 foo file displays foo and the last 5 lines


If you want to import these contents into a specified file, you can do this

grep -C 5 foo file > newfile

This is useful for finding problems in server logs

 

Count the number of keywords that contain a certain keyword

grep -o keyword fileName | wc -l
If a line has at most one keyword, it can be abbreviated as:
grep -c keyword fileName


The way to check the grep version is

grep -V


cat aipg.log | grep 200604000003947-1272161791427

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324827087&siteId=291194637