I have a multi line log entry format that I need to process.
The log looks something like this:
--START--
Device=B
Data=asdfasdf
Lorem=Ipsum
--END--
--START--
Device=A
Data=asdfasdf
Lorem=Ipsum
--END--
--START--
Device=B
Data=asdfasdf
--END--
--START--
Device=A
Data=asdfasdf
--END--
--START--
Device=B
Data=asdfasdf
--END--
--START--
Device=C
Data=asdfasdf
Lorem=Ipsum
--END--
I want to print everything between --START--
and --END--
if a particular pattern is matched.
e.g:
Print all entries where Device=A
--START--
Device=A
Data=asdfasdf
Lorem=Ipsum
--END--
--START--
Device=A
Data=asdfasdf
--END--
All I've been able to do so far is write:
sed -e -n '/--START--/,/--END--/p' < input
Which effectively prints the input but I think I need to add {}
to filter with N
and then print if that condition matches.
I also think I'm completely lost.
Any idea on how to print multiple lines if a single line matches a condition?