I have a log file where each entry is delimited by a series of ---
, similar to this:
-----------------
Name=Operation1
Time: 100
Status=Success
-----------------
Name=Operation1
Time: 500
Status=Failure
-----------------
Name=Operation2
Time: 200
Status=Success
-----------------
Name=Operation2
Time: 800
Status=Failure
-----------------
I would like to extract all of the entries matching certain criteria (i.e. all entries where Name=Operation1
or all entries where Status=Failure
). I thought I could use agrep as follows: agrep -d "---*" -e "Name=Operation1" mylogfile > myfilteredlogfile
but after inspecting the file it doesn't seem to filter as I expected. What's wrong with my filtering and how can I extract my desired entries?