Skip to main content
11 events
when toggle format what by license comment
Oct 29, 2022 at 0:04 comment added alper I have tired -1 for the previos line but it did not work
Dec 21, 2018 at 7:36 comment added Gilles 'SO- stop being evil' @A.K. If you just want to delete the matching line, it's even simpler: sed '/bar/d'
Dec 21, 2018 at 0:10 comment added A. K. I actually wanted to delete the matching line so I just replaced +1 with +0 and it worked! like: sed '/bar/,+0 d'
Oct 31, 2018 at 4:06 comment added Tom Saleeba To break down the command: the first part /bar/,+1/ is a sed address (gnu.org/software/sed/manual/sed.html#sed-addresses) that says start at the regexp /bar/, then a , as a separator between start/end addresses, and end +1 lines (from the start). Then the d is the command (delete)
Mar 2, 2018 at 15:58 comment added Pandya @Gilles Thanks that worked, but I might have done some mistake and asked the question.
Feb 7, 2018 at 12:44 comment added Gilles 'SO- stop being evil' @Pandya That's different. You can use e.g. sed '/math/q'
Feb 7, 2018 at 9:24 comment added Pandya If I want to remove all the lines after math then?
Apr 2, 2017 at 9:55 comment added AJP sed '/bar/d' if you just want to "Remove line containing certain string" and not the next.
Nov 20, 2012 at 9:37 vote accept jakub.g
Nov 20, 2012 at 9:30 comment added jakub.g +1 for the length :) In my particular example I don't have consecutive bars so this one is super easy to remember.
Nov 19, 2012 at 23:34 history answered Gilles 'SO- stop being evil' CC BY-SA 3.0