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

Cameron Simpson <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 13Jul2012 18:17, n22e113 <[email protected]> wrote:
| Note: Tried to post the following a few days ago; trying again:
| > Does the blank line immediately follow the short line, or then can be other
| > lines in between?
| >
| How about providing examples for both? ;-)

You seem confused. It is _your_ data file. Asking people to provide a
million programs for a whole bunch of scenarios is a bit... greedy.

(And you seem to have dropped the attribution of who wrote the "> "
bits.)

| > If it's the former, then this should work:
| >
| > sed '/.\{80\}/! {
| > n
| > /^$/d
| > }'
|
| The above didn't work from inside a bash script:
|
| #!/bin/bash
| sed '/.\{80\}/! {
| n
| /^$/d}' file1.txt | less

So... Tell us what _did_ happen. Provide the content of file1.txt and
the output you got, along with the output you _wanted_.

And did you experiment much? With and without sed's -r option? (Are you
using GNU sed or a more stock version?)

Saying it "didn't work" does nothing to help the people trying to help
you. They need to know exactly what data you fed to the script, and
exactly what you hoped to get out the other end.

Cheers,
-- 
Cameron Simpson <[email protected]>

Don't have awk? Use this simple sh emulation:
    #!/bin/sh
    echo 'Awk bailing out!' >&2
    exit 2
- Tom Horsley <[email protected]>
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.