Wednesday, April 14, 2021

How to remove paragraphs with specific text from my text file?


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+unsubscribe@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.

No comments:

Post a Comment