https://stackoverflow.com/questions/32379801/grep-whole-paragraphs-of-a-text-containing-a-specific-keyword
suggests using either awk for sed and gives examples. On Wednesday, April 14, 2021 at 8:30:42 AM UTC-4 Salman Halim wrote: > Try (untested): > > :g/SQL command completed successfully/normal! dap > > Salman > > -- > > Salman > > On Wed, Apr 14, 2021, 08:13 Igor <igo...@gmail.com> wrote: > >> >> Hi, >> I have 130 thousand lines of output file. >> - Each output is in separate paragraph. >> - Each paragraph has at least two or more rows. >> I would like to remove all paragraphs that ends with (this text is alway >> last line in paragraph): >> DB20000I The SQL command completed successfully. >> >> Or simpler: I want to keep all paragraphs that has "SQLSTATE=" (without >> double quotes) in the last line. >> >> *Sample output file:* >> >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> xxx xxxxxx >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> xx xxxxxxxx xxxxxx xx xxxxxx >> xxxxx xx xxxxx yyyyyyy yyyyy. SQLSTATE=01550 >> >> xx xxxxxx >> SQLSTATE=42704 >> >> xx xxxxxx >> xx xxx xxxxxxx >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> >> *I want to remove:* >> >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> xxx xxxxxx >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> xx xxxxxx >> xx xxx xxxxxxx >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> xxx xxxxxx >> DB20000I The SQL command completed successfully. >> >> *I want to keep:* >> >> xx xxxxxxxx xxxxxx xx xxxxxx >> xxxxx xx xxxxx yyyyyyy yyyyy. SQLSTATE=01550 >> >> xx xxxxxx >> SQLSTATE=42704 >> >> How to accomplish this with vim? >> >> -- >> -- >> You received this message from the "vim_use" maillist. >> Do not top-post! Type your reply below the text you are replying to. >> For more information, visit http://www.vim.org/maillist.php >> >> --- >> You received this message because you are subscribed to the Google Groups >> "vim_use" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to vim_use+u...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/vim_use/362a2060-58a7-465a-8f7c-d837717f3347n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/vim_use/362a2060-58a7-465a-8f7c-d837717f3347n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a8e22af6-8aef-4716-90e0-b104f16762fcn%40googlegroups.com.