Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • One difference from grep is handling overlapping matches. Say if data_one immediately followed header_one, it would be printed twice — once as part of /header_/,+1 address range, once as part of /^data_/,+2 range. Commented May 17, 2023 at 8:27
  • Numbering the lines with cat filename | nl | sed -n -e '/\theader_/,+1p' -e '/\tdata_/,+2p' helps figure out where lines were skipped (and where they're printed twice)... Commented May 17, 2023 at 8:30