Hi,
I have a log file I want to parse. Lines normally begin like this:
2022-04-07 12:46:14,624-0400 some text here
2022-04-07 12:46:14,625-0400 some more text here
2022-04-07 12:46:14,625-0400 ERROR something
oh my gosh
this is terrible
bad error message
2022-04-07 12:46:14,625-0400 some more text here
2022-04-07 12:46:14,625-0400 some more more text here
I want to capture from the beginning of an error line until the next new line with the timestamp.
What I tried to do is this:
awk '/ERROR something/,/^2022/' mylog.txt
But this didn't work because the pattern match works on my first line. I want to find the next line with the string ^2022, so basically print the current line until the next line of ^2022.
The desired output would be:
2022-04-07 12:46:14,625-0400 ERROR something
oh my gosh
this is terrible
bad error message
Thanks in advance!
I have a log file I want to parse. Lines normally begin like this:
2022-04-07 12:46:14,624-0400 some text here
2022-04-07 12:46:14,625-0400 some more text here
2022-04-07 12:46:14,625-0400 ERROR something
oh my gosh
this is terrible
bad error message
2022-04-07 12:46:14,625-0400 some more text here
2022-04-07 12:46:14,625-0400 some more more text here
I want to capture from the beginning of an error line until the next new line with the timestamp.
What I tried to do is this:
awk '/ERROR something/,/^2022/' mylog.txt
But this didn't work because the pattern match works on my first line. I want to find the next line with the string ^2022, so basically print the current line until the next line of ^2022.
The desired output would be:
2022-04-07 12:46:14,625-0400 ERROR something
oh my gosh
this is terrible
bad error message
Thanks in advance!