Skip to main content
2 of 3
added 7 characters in body
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

If the file were correct xml, you could use an xml parsing tool.

Otherwise, if there were no other (nested) div section inside that section, you could have done:

pcregrep -Mo '(?s)<div[^>]*id="id1".*?</div>' the-file.html
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k