grep multiline entities
In case you have a good separator of multiline entities in a file:
$ ls
update.log
$ cat update.log
Id: 2837
Field1: foo
Field2: bar
Field3: 12.4
---
Id: 44323
Field1: qux
Field2: xxyy
Status: ERROR
Id: 74738
Field1: baz
Field3: boo
$ csplit update.log '/^Id:/' '{*}'
0
51
50
35
$ ls
update.log xx00 xx01 xx02 xx03
$ grep 'Status: ERROR' xx*
xx02:Status: ERROR
$ grep 'Status: ERROR' xx* | cut -d':' -f1 | xargs -n1 head -1
Id: 44323
$
Advertisement