Re: Delete Next Blank Line IFF Current Line is Less than 80 Characters

Davide Brini <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On Wed, 11 Jul 2012 01:06:48 -0400, n22e113 <[email protected]> wrote:

> Hello,Seders,
> How can I delete the next blank line if the current line is less than 80 
> characters from within a bash script?
> Example:
> 
> "This line is a Heading
> 
> This line starts as a paragraph with one or more than one sentences and 
> the paragraph is more than 80 characters."
> 
> Like to delete the blank line between the two lines above.
> Thanks,Kwon

Does the blank line immediately follow the short line, or then can be other
lines in between?

If it's the former, then this should work:

sed '/.\{80\}/! {
  n
  /^$/d
}'

-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.