This question already has an answer here:

We have a config file which consists of more than 24000 lines.

I am stuck in one task. I need to segregate the lines starting as below (service definition of specific host in icinga2)

     Object Service "<host_name>"{

And ending with


Files consists multiple other entries as well

I need to filter specific hosts definition alone.

marked as duplicate by Sparhawk, Rui F Ribeiro, Thomas, G-Man, Stephen Harris Dec 3 '18 at 0:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Check jq utility as icinga configs are JSON files – Romeo Ninov Dec 2 '18 at 9:37

Very simple sed approach:

sed -n '/incinga2/,/}/p' file

You might be better off with the commented on tools (jq) if the file's structure becomes more complicated, though.

Not the answer you're looking for? Browse other questions tagged or ask your own question.