Wednesday, April 14, 2021

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

Hi Igor


assuming paragraph means there are empty lines between the paragraphs, awk uses the empty string as a record separator specifying the same. So


gawk /SQLSTATE=/ RS= ORS=\n\n datafile > a


creates a file in the same format, but with only those paragraphs containing SQLSTATE= . Not even the equals sign is a metacaracter, so no escaping is needed. When redirecting output, I use the convention that a is a transitory file, that can always be overwritten. If I wish to keep it, I then rename it.


As far as I can see this will work in an MS command window, or Unix versions. If you don't have an awk in the system gnu awk is downloadable. It is an executable. It relies on no dlls.


regards - Chris



------ Original Message ------
From: arocker@Vex.Net
To: vim_use@googlegroups.com
Sent: Wednesday, 14 Apr, 2021 At 14:35
Subject: Re: How to remove paragraphs with specific text from my text file?

igor2x@gmail.com stated

I have 130 thousand lines of output file.
- Each output is in separate paragraph.
- Each paragraph has at least two or more rows.
&c

That was a model example of a problem statement; clear illustration of
sample input and the desired output.

I'd be inclined to go with the awk/sed type solutions, if only to make a
clear series of steps, keeping an original file intact, at least until
it's clear that it is no longer required.


--
--
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/58f2565c67921d04b06cb2e025d3951c.squirrel%40webmail.vybenetworks.com.

No comments:

Post a Comment