A useful Linux command tac+grep

Encountered a problem,
I want to see some information, there are too many logs.
1. Generally, tailf xx.log is used to reproduce it again.
But sometimes others are testing you as well, and it's not easy to see.

2. If you use less and then search, there are too many pages, which is troublesome.

3. Use cat xx.log | grep abc
but this will sometimes grep a lot of things, and grep from front to back.

4. Change to tac xx.log | grep -m2 -C2 abc
This will make it look much better. Tac = cat is the reverse, that is, the number of results of the cat file grep -m search

from the back to the front is set to      -C (uppercase) The number of search results next to n lines of output


Guess you like

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