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.

9
  • 1
    +1 for the length :) In my particular example I don't have consecutive bars so this one is super easy to remember. Commented Nov 20, 2012 at 9:30
  • 15
    sed '/bar/d' if you just want to "Remove line containing certain string" and not the next. Commented Apr 2, 2017 at 9:55
  • If I want to remove all the lines after math then? Commented Feb 7, 2018 at 9:24
  • 2
    @Pandya That's different. You can use e.g. sed '/math/q' Commented Feb 7, 2018 at 12:44
  • 2
    @A.K. If you just want to delete the matching line, it's even simpler: sed '/bar/d' Commented Dec 21, 2018 at 7:36