I am very stumped. I am searching multiple files for multiple lines that look like this (by find
-ing the desired start date) and piping to grep so I can extract group of lines with this command:
find logdir/ -type f -regextype sed -regex ".*2016-06-22.*" | while read fname
do
zgrep -a -P -B9 ".*COOKTHE.*slave.*" $fname
done
So I can output groups of lines this:
2017-05-10 12:14:54 DEBUG[dispatcher-1533] something.else.was.here.Pia - http://server:9999/cookout/123123123123/entry c7aab5a3-0dab-4ce1-b188-b5370007c53c request:
HEADERS:
Host: server:9999
Accept: */*
User-Agent: snakey-requests/2.12.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Timeout-Access: <function1>
CONTENT:
{"operation": "COOKTHE", "reason": "sucker verified", "username": "slave"}
I'm trying to extract from the first line match, the entire string date pattern (2017-05-10 12:14:54
) the digit pattern 123123123123
and from the last line, the entire line match. ({"operation": "COOKTHE", "reason": "sucker verified", "username": "slave"}
)
How can I extract these with grep, sed, or awk?