Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

1 1 was a race-horse, 2 2 was 1 2. When 1 1 1 1 race, 2 2 1 1 2.


devel / comp.unix.shell / delete one of two consecutive line

SubjectAuthor
* delete one of two consecutive lineHarry
+* Re: delete one of two consecutive lineEd Morton
|`- Re: delete one of two consecutive lineHarry
+* Re: delete one of two consecutive lineLew Pitcher
|`- Re: delete one of two consecutive lineEd Morton
+- Re: delete one of two consecutive lineKaz Kylheku
+* Re: delete one of two consecutive lineRandal L. Schwartz
|`* Re: delete one of two consecutive lineWilliam Unruh
| `- Re: delete one of two consecutive lineRandal L. Schwartz
`* Re: delete one of two consecutive lineJanis Papanagnou
 +- Re: delete one of two consecutive lineHarry
 +- Re: delete one of two consecutive lineHarry
 `* Re: delete one of two consecutive lineWilliam Unruh
  +- Re: delete one of two consecutive lineSpiros Bousbouras
  +* Re: delete one of two consecutive lineJanis Papanagnou
  |+* Re: delete one of two consecutive lineJanis Papanagnou
  ||`* No fields is not necessarily an empty line (Was: delete one of two consecutive lKenny McCormack
  || `- Re: No fields is not necessarily an empty line (Was: delete one ofJanis Papanagnou
  |`- Re: delete one of two consecutive lineWilliam Unruh
  `- Re: delete one of two consecutive lineAragorn

1
delete one of two consecutive line

<1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3850&group=comp.unix.shell#3850

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a0c:9b96:: with SMTP id o22mr41478536qve.23.1622005289290;
Tue, 25 May 2021 22:01:29 -0700 (PDT)
X-Received: by 2002:a0c:8bd1:: with SMTP id a17mr41520111qvc.62.1622005289116;
Tue, 25 May 2021 22:01:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 25 May 2021 22:01:28 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
Subject: delete one of two consecutive line
From: harryooo...@hotmail.com (Harry)
Injection-Date: Wed, 26 May 2021 05:01:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Wed, 26 May 2021 05:01 UTC

I have an email attachment ATT000001.xml with content like below.
Note that there are two consecutive lines <?xml version="1.0"?>.
How could I use sed or awk to delete one of them?

Note that the two <?xml version="1.0"?> lines causes "strict parse error" when I renamed ATT000001.xml as xxx.xls and tried to open it.
Normally there is only one such <?xml version="1.0"?> line generated in such email attachment; but occasionally two were generated, and gave me trouble opening the attachment.

TIA

--
Content-Disposition: attachment; filename="xxx.xls";
<?xml version="1.0"?>
<?xml version="1.0"?>
<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<ss:Styles> <ss:Style ss:ID="1"> <ss:Font ss:Bold="1"/></ss:Style>
<ss:Style ss:ID="s65"> <ss:Alignment ss:Vertical="Top" ss:WrapText="1"/></ss:Style> </ss:Styles>
<ss:Worksheet ss:Name="ESI report"><ss:Table>
<ss:Column ss:Width="100"/>
<ss:Column ss:Width="60"/>
<ss:Column ss:Width="60"/>
<ss:Column ss:Width="70"/>
<ss:Column ss:Width="100"/>
<ss:Column ss:Width="100"/>
<ss:Column ss:Width="140"/>
<ss:Column ss:Width="640"/>
[snip]
--

Re: delete one of two consecutive line

<s8ldip$a96$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3851&group=comp.unix.shell#3851

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 07:05:46 -0500
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <s8ldip$a96$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 May 2021 12:05:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e3ad9728c27b895be72d84d1fedcf18b";
logging-data="10534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pLq42K5nyGunkgYbbwS7i"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:/lgztvBB36p3PHrcO9UBN7CqByM=
In-Reply-To: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210525-14, 05/25/2021), Outbound message
 by: Ed Morton - Wed, 26 May 2021 12:05 UTC

On 5/26/2021 12:01 AM, Harry wrote:
> I have an email attachment ATT000001.xml with content like below.
> Note that there are two consecutive lines <?xml version="1.0"?>.
> How could I use sed or awk to delete one of them?

awk '!( ($0=="<?xml version=\"1.0\"?>") && seen[$0]++ )' file

Ed.

Re: delete one of two consecutive line

<152be763-49f9-41d2-9765-ba6335a7c5a8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3852&group=comp.unix.shell#3852

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:6e8f:: with SMTP id c15mr22247021qtv.122.1622038908129;
Wed, 26 May 2021 07:21:48 -0700 (PDT)
X-Received: by 2002:a37:2792:: with SMTP id n140mr40433850qkn.478.1622038907928;
Wed, 26 May 2021 07:21:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 26 May 2021 07:21:47 -0700 (PDT)
In-Reply-To: <s8ldip$a96$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com> <s8ldip$a96$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <152be763-49f9-41d2-9765-ba6335a7c5a8n@googlegroups.com>
Subject: Re: delete one of two consecutive line
From: harryooo...@hotmail.com (Harry)
Injection-Date: Wed, 26 May 2021 14:21:48 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Wed, 26 May 2021 14:21 UTC

On Wednesday, May 26, 2021 at 5:05:50 AM UTC-7, Ed Morton wrote:

> awk '!( ($0=="<?xml version=\"1.0\"?>") && seen[$0]++ )' file

Great! It works!

Re: delete one of two consecutive line

<s8lp02$onh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3853&group=comp.unix.shell#3853

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 15:20:35 -0000 (UTC)
Organization: The Pitcher Digital Freehold
Lines: 15
Message-ID: <s8lp02$onh$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 26 May 2021 15:20:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="22aa8be85f525ff509610fd666c33d81";
logging-data="25329"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QZ2/TkiSVFBE1tiypmB0Nbb3XVLWzEpc="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:xdCBcVNTW37IS2qgu6u/5a3B36E=
 by: Lew Pitcher - Wed, 26 May 2021 15:20 UTC

On Tue, 25 May 2021 22:01:28 -0700, Harry wrote:

> I have an email attachment ATT000001.xml with content like below.
> Note that there are two consecutive lines <?xml version="1.0"?>.
> How could I use sed or awk to delete one of them?

Ed Morton supplied an awk solution.

Here's my alternative non-sed, non-awk, solution:
tail -n+2 ATT000001.xml

HTH
--
Lew Pitcher
"In Skills, We Trust"

Re: delete one of two consecutive line

<s8lscf$mkj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3854&group=comp.unix.shell#3854

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 11:18:23 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <s8lscf$mkj$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8lp02$onh$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 May 2021 16:18:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e3ad9728c27b895be72d84d1fedcf18b";
logging-data="23187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18omKerBNlGjLyTJEDIhBXv"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:i3XUwpSylDJ5DP06caPqvT+emDI=
In-Reply-To: <s8lp02$onh$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210525-14, 05/25/2021), Outbound message
 by: Ed Morton - Wed, 26 May 2021 16:18 UTC

On 5/26/2021 10:20 AM, Lew Pitcher wrote:
> On Tue, 25 May 2021 22:01:28 -0700, Harry wrote:
>
>> I have an email attachment ATT000001.xml with content like below.
>> Note that there are two consecutive lines <?xml version="1.0"?>.
>> How could I use sed or awk to delete one of them?
>
> Ed Morton supplied an awk solution.
>
> Here's my alternative non-sed, non-awk, solution:
> tail -n+2 ATT000001.xml
>

That would delete the line

Content-Disposition: attachment; filename="xxx.xls";

at the top of the OPs sample input shown in the question (I'm assuming
everything below the "--" in the question is what the OP is working with
as input) and/or delete the one and only

<?xml version="1.0"?>

in those cases where it isn't duplicated (the OP said "occasionally...").

Ed.

Re: delete one of two consecutive line

<20210526094141.421@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3855&group=comp.unix.shell#3855

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 16:47:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <20210526094141.421@kylheku.com>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
Injection-Date: Wed, 26 May 2021 16:47:28 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="6eeb1ec3f7c3eb0827e4bdc11688a603";
logging-data="24896"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xp6+z9bCUJNzIHTaBzM6xQJf4nk0LvII="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:cQaUdxDPfb16EvN0AoXioUzkdjU=
 by: Kaz Kylheku - Wed, 26 May 2021 16:47 UTC

On 2021-05-26, Harry <harryooopotter@hotmail.com> wrote:
> I have an email attachment ATT000001.xml with content like below.
> Note that there are two consecutive lines <?xml version="1.0"?>.
> How could I use sed or awk to delete one of them?
>
> Note that the two <?xml version="1.0"?> lines causes "strict parse error" when I renamed ATT000001.xml as xxx.xls and tried to open it.
> Normally there is only one such <?xml version="1.0"?> line generated in such email attachment; but occasionally two were generated, and gave me trouble opening the attachment.
>
> TIA
>
> --
> Content-Disposition: attachment; filename="xxx.xls";
>
><?xml version="1.0"?>
><?xml version="1.0"?>
><ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
><ss:Styles> <ss:Style ss:ID="1"> <ss:Font ss:Bold="1"/></ss:Style>
><ss:Style ss:ID="s65"> <ss:Alignment ss:Vertical="Top" ss:WrapText="1"/></ss:Style> </ss:Styles>
> <ss:Worksheet ss:Name="ESI report"><ss:Table>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="60"/>
> <ss:Column ss:Width="60"/>
> <ss:Column ss:Width="70"/>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="140"/>
> <ss:Column ss:Width="640"/>
> [snip]
> --

txr -c '@(bind x "<?xml version=\"1.0\"?>")
@(repeat)
@ (cases)
@x
@x
@ (bind line x)
@ (or)
@line
@ (end)
@ (do (put-line line))
@(end)' < input > output

Explanation:

@(bind x "<?xml version=\"1.0\"?>")

Bind variable x to the string we are looking for.

@(repeat)

Scan through the lines of input, doing multi-line matches at each line.

@ (cases)

Match multiple cases separated by @(or)

@x
@x

Match two consecutive lines, each of which is identical to x.

@ (bind line x)

If the lines matched bind the line variable to x. This always succeeds.

@ (or)
@line

Otherwise, if the previous case didn't match, just match the current
line, binding it to the line variable.

@ (end)

End of cases construct. We now have a line variable.

@ (do (put-line line))

Output the line variable as a line.

@(end)

End of repeat construct.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: delete one of two consecutive line

<864kep4c92.fsf@red.stonehenge.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3856&group=comp.unix.shell#3856

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
From: mer...@stonehenge.com (Randal L. Schwartz)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
x-mayan-date: Long count = 13.0.8.9.18; tzolkin = 1 Etznab; haab = 16 Zip
Message-ID: <864kep4c92.fsf@red.stonehenge.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix)
Cancel-Lock: sha1:y0sMHsdhxNkZtRRn2UEWstCLh5k=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 19
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Wed, 26 May 2021 18:03:06 UTC
Date: Wed, 26 May 2021 10:48:41 -0700
X-Received-Bytes: 1710
X-Received-Body-CRC: 806591424
X-Original-Bytes: 1659
 by: Randal L. Schwartz - Wed, 26 May 2021 17:48 UTC

>>>>> "Harry" == Harry <harryooopotter@hotmail.com> writes:

Harry> I have an email attachment ATT000001.xml with content like below.
Harry> Note that there are two consecutive lines <?xml version="1.0"?>.
Harry> How could I use sed or awk to delete one of them?

Surprised not to see a sed solution yet. sed has a great finite state
machine built in. I've done some truly horrific things with that.

I stared at the sed manual for a few minutes, but can't rememeber enough
of my hackery, but it would basically be 3 states, before seeing the
first one (print it and repeat), seeing the first one (print it, go
to next state), then print anything that's not it.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

Re: delete one of two consecutive line

<s8m36f$362$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3857&group=comp.unix.shell#3857

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 18:14:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <s8m36f$362$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<864kep4c92.fsf@red.stonehenge.com>
Injection-Date: Wed, 26 May 2021 18:14:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bb63b9352119fdcc0bb004e418e50a80";
logging-data="3266"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JYOjC5lwn3MqXLW/mLGUW"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:wsy5AZc/j8sCE2ohFaaRsB2P74Y=
 by: William Unruh - Wed, 26 May 2021 18:14 UTC

On 2021-05-26, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Harry" == Harry <harryooopotter@hotmail.com> writes:
>
>Harry> I have an email attachment ATT000001.xml with content like below.
>Harry> Note that there are two consecutive lines <?xml version="1.0"?>.
>Harry> How could I use sed or awk to delete one of them?
>
> Surprised not to see a sed solution yet. sed has a great finite state
> machine built in. I've done some truly horrific things with that.
>
> I stared at the sed manual for a few minutes, but can't rememeber enough
> of my hackery, but it would basically be 3 states, before seeing the
> first one (print it and repeat), seeing the first one (print it, go
> to next state), then print anything that's not it.

He said that he wanted to eliminate one of two consecutive lines. Not
that line repeated anywhere in the file as I read it. Thus you have to
reset the state if the next line is not the the repeat. This is also
true of the awk suggestions.

>

Re: delete one of two consecutive line

<s8ma2l$31g$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3858&group=comp.unix.shell#3858

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 22:12:05 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 78
Message-ID: <s8ma2l$31g$1@news-1.m-online.net>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
NNTP-Posting-Host: 2001:a61:252a:da01:c195:cab3:269e:852d
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1622059925 3120 2001:a61:252a:da01:c195:cab3:269e:852d (26 May 2021 20:12:05 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Wed, 26 May 2021 20:12:05 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
 by: Janis Papanagnou - Wed, 26 May 2021 20:12 UTC

On 26.05.2021 07:01, Harry wrote:
> I have an email attachment ATT000001.xml with content like below.
> Note that there are two consecutive lines <?xml version="1.0"?>.
> How could I use sed or awk to delete one of them?

One way could be

awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'

(You may stop reading here.)

First some introductory comments referring to other posts...

Well, there are many ways to skin a cat. We can also make some
assumptions - because it's possible to do so or because we are
guessing - to keep the solutions terse (as Ed did and William
pointed out), or to extend the range of faulty data to be able
to handle by a solution (like the code shown).

The first hint, though, would be to get the process that creates
such wrong data fixed! (Instead of letting arbitrary amounts of
people work around the issue individually.)

We've already seen an awk solution, with a hint in a followup
about a limit it inherently has. But we can also rewrite that
algorithm, since it's so simple to do with awk[*]. We can also
try memorizing how that would be done more cryptically in sed,
were another poster obviously had difficulties to recall.

Just for a variant I want to provide another awk approach[**]

awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'

which has the property to keep only one of multiple (2+) and
only consecutive lines matching the passed pattern.[***]

Janis

[*] I abstain from posting an update of that awk code.

[**] Probably a bit cryptic as well, though I simply derived it
from another algorithm I suggested a couple years ago to squeeze
multiple empty lines that separate text blocks to a single empty
line: awk 'NF,!NF'

[***] It has an own (here also irrelevant) restriction if the N
pattern(s) appear as the first line(s) of the files.

> Note that the two <?xml version="1.0"?> lines causes "strict parse
> error" when I renamed ATT000001.xml as xxx.xls and tried to open it.
> Normally there is only one such <?xml version="1.0"?> line generated
> in such email attachment; but occasionally two were generated, and gave
> me trouble opening the attachment.
>
> TIA
>
> --
> Content-Disposition: attachment; filename="xxx.xls";
>
> <?xml version="1.0"?>
> <?xml version="1.0"?>
> <ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
> <ss:Styles> <ss:Style ss:ID="1"> <ss:Font ss:Bold="1"/></ss:Style>
> <ss:Style ss:ID="s65"> <ss:Alignment ss:Vertical="Top" ss:WrapText="1"/></ss:Style> </ss:Styles>
> <ss:Worksheet ss:Name="ESI report"><ss:Table>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="60"/>
> <ss:Column ss:Width="60"/>
> <ss:Column ss:Width="70"/>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="100"/>
> <ss:Column ss:Width="140"/>
> <ss:Column ss:Width="640"/>
> [snip]
> --
>

Re: delete one of two consecutive line

<86zgwh2pgm.fsf@red.stonehenge.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3859&group=comp.unix.shell#3859

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
From: mer...@stonehenge.com (Randal L. Schwartz)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<864kep4c92.fsf@red.stonehenge.com> <s8m36f$362$1@dont-email.me>
x-mayan-date: Long count = 13.0.8.9.18; tzolkin = 1 Etznab; haab = 16 Zip
Message-ID: <86zgwh2pgm.fsf@red.stonehenge.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix)
Cancel-Lock: sha1:+WPdeDWvGHoM7j4A5aKCdBll2kM=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 17
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Wed, 26 May 2021 21:03:06 UTC
Date: Wed, 26 May 2021 13:46:17 -0700
X-Received-Bytes: 1768
 by: Randal L. Schwartz - Wed, 26 May 2021 20:46 UTC

>>>>> "William" == William Unruh <unruh@invalid.ca> writes:

William> On 2021-05-26, Randal L. Schwartz <merlyn@stonehenge.com> wrote:

William> He said that he wanted to eliminate one of two consecutive lines. Not
William> that line repeated anywhere in the file as I read it. Thus you have to
William> reset the state if the next line is not the the repeat. This is also
William> true of the awk suggestions.

Still sounds like a fun sed challenge. One of the things I remember
creating was a backslash-at-end-of-line folding action.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

Re: delete one of two consecutive line

<dd934b43-eb4d-4203-ba37-52c14b5d9355n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3860&group=comp.unix.shell#3860

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:6e8f:: with SMTP id c15mr436774qtv.122.1622068492349;
Wed, 26 May 2021 15:34:52 -0700 (PDT)
X-Received: by 2002:ac8:774c:: with SMTP id g12mr431943qtu.268.1622068492187;
Wed, 26 May 2021 15:34:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 26 May 2021 15:34:51 -0700 (PDT)
In-Reply-To: <s8ma2l$31g$1@news-1.m-online.net>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com> <s8ma2l$31g$1@news-1.m-online.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dd934b43-eb4d-4203-ba37-52c14b5d9355n@googlegroups.com>
Subject: Re: delete one of two consecutive line
From: harryooo...@hotmail.com (Harry)
Injection-Date: Wed, 26 May 2021 22:34:52 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Wed, 26 May 2021 22:34 UTC

On Wednesday, May 26, 2021 at 1:12:09 PM UTC-7, Janis Papanagnou wrote:

> Just for a variant I want to provide another awk approach[**]
>
> awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'
>
> which has the property to keep only one of multiple (2+) and
> only consecutive lines matching the passed pattern.[***]
>
> Janis

Nice solution too.
I tried with my file having two set of 2 consecutive <?xml version="1.0"?> lines,
and this solution eliminates the two duplicated lines (one for each set).

In my particular situation, there won't be two set of consecutive <?xml version="1.0"?> lines.

Just make the story short, the programmer was writing two consecutive <?xml version="1.0"?> lines in his program, and said that sendmail would eat up one of them (as a sendmail usual behaviour).
And occasionally, this "usual sendmail behaviour" did not occur, making the particular excel file
unable to open. I am just on the receiving end of the attachment, which should have only one <?xml version="1.0"?> line per attachment.
But in case there are multiple attachments in the sendmail file, your solution would get rid of the multiple duplicates :-)

Re: delete one of two consecutive line

<e33e2895-bd00-49c6-8015-88310803dd10n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3861&group=comp.unix.shell#3861

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:7c50:: with SMTP id o16mr494315qtv.153.1622070270432;
Wed, 26 May 2021 16:04:30 -0700 (PDT)
X-Received: by 2002:a05:620a:4090:: with SMTP id f16mr494369qko.225.1622070270298;
Wed, 26 May 2021 16:04:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 26 May 2021 16:04:30 -0700 (PDT)
In-Reply-To: <s8ma2l$31g$1@news-1.m-online.net>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com> <s8ma2l$31g$1@news-1.m-online.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e33e2895-bd00-49c6-8015-88310803dd10n@googlegroups.com>
Subject: Re: delete one of two consecutive line
From: harryooo...@hotmail.com (Harry)
Injection-Date: Wed, 26 May 2021 23:04:30 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Wed, 26 May 2021 23:04 UTC

On Wednesday, May 26, 2021 at 1:12:09 PM UTC-7, Janis Papanagnou wrote:
> On 26.05.2021 07:01, Harry wrote:
> > I have an email attachment ATT000001.xml with content like below.
> > Note that there are two consecutive lines <?xml version="1.0"?>.
> > How could I use sed or awk to delete one of them?
> One way could be
>
> awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'

Nice solution too.
I tried with my file having two set of 2 consecutive <?xml version="1.0"?> lines,
and this solution eliminates the two duplicated lines (one for each set).

[Edited]
I deleted what I said on "sendmail usual behaviour" ....
Actually the programmer wrote "smtp stripping first line so extra line."

Re: delete one of two consecutive line

<s8mkl1$2g8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3862&group=comp.unix.shell#3862

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Wed, 26 May 2021 23:12:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <s8mkl1$2g8$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8ma2l$31g$1@news-1.m-online.net>
Injection-Date: Wed, 26 May 2021 23:12:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8c09b737a0d77987b2e1486612293a98";
logging-data="2568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kr0IjyfByv6mkr/of1Y/5"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:rujDOZ77C01fmURqKZoFRBdi6/I=
 by: William Unruh - Wed, 26 May 2021 23:12 UTC

On 2021-05-26, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> On 26.05.2021 07:01, Harry wrote:
....
> Just for a variant I want to provide another awk approach[**]
>
> awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'
>
> which has the property to keep only one of multiple (2+) and
> only consecutive lines matching the passed pattern.[***]
....
>
> [**] Probably a bit cryptic as well, though I simply derived it
> from another algorithm I suggested a couple years ago to squeeze
> multiple empty lines that separate text blocks to a single empty
> line: awk 'NF,!NF'

This reminds me of a lecture at a Seminar given by one of the profs
here.

"I gave a seminar 14 years ago on this topic, and I assume you all
remember that."

Yes, it is crytptic. Could you please expand?

Re: delete one of two consecutive line

<range-pattern@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3863&group=comp.unix.shell#3863

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx43.ams4.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Message-ID: <range-pattern@bongo-ra.co>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com> <s8ma2l$31g$1@news-1.m-online.net> <s8mkl1$2g8$1@dont-email.me>
In-Reply-To: <s8mkl1$2g8$1@dont-email.me>
X-Organisation: Weyland-Yutani
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 27
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Wed, 26 May 2021 23:25:36 UTC
Organization: virginmedia.com
Date: Wed, 26 May 2021 23:25:36 GMT
X-Received-Bytes: 1764
 by: Spiros Bousbouras - Wed, 26 May 2021 23:25 UTC

On Wed, 26 May 2021 23:12:33 -0000 (UTC)
William Unruh <unruh@invalid.ca> wrote:
> On 2021-05-26, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> > On 26.05.2021 07:01, Harry wrote:
> ...
> > Just for a variant I want to provide another awk approach[**]
> >
> > awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'
> >
> > which has the property to keep only one of multiple (2+) and
> > only consecutive lines matching the passed pattern.[***]
> ...
> >
> > [**] Probably a bit cryptic as well, though I simply derived it
> > from another algorithm I suggested a couple years ago to squeeze
> > multiple empty lines that separate text blocks to a single empty
> > line: awk 'NF,!NF'
>
> This reminds me of a lecture at a Seminar given by one of the profs
> here.
>
> "I gave a seminar 14 years ago on this topic, and I assume you all
> remember that."
>
> Yes, it is crytptic. Could you please expand?

Are you familiar with range patterns in AWK ?

Re: delete one of two consecutive line

<s8mpmf$7m0$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3864&group=comp.unix.shell#3864

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Thu, 27 May 2021 02:38:39 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 47
Message-ID: <s8mpmf$7m0$1@news-1.m-online.net>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8ma2l$31g$1@news-1.m-online.net> <s8mkl1$2g8$1@dont-email.me>
NNTP-Posting-Host: 2001:a61:252a:da01:c904:461f:2bcc:f696
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1622075919 7872 2001:a61:252a:da01:c904:461f:2bcc:f696 (27 May 2021 00:38:39 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Thu, 27 May 2021 00:38:39 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <s8mkl1$2g8$1@dont-email.me>
 by: Janis Papanagnou - Thu, 27 May 2021 00:38 UTC

On 27.05.2021 01:12, William Unruh wrote:
> On 2021-05-26, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>> On 26.05.2021 07:01, Harry wrote:
> ...
>> Just for a variant I want to provide another awk approach[**]
>>
>> awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'
>>
>> which has the property to keep only one of multiple (2+) and
>> only consecutive lines matching the passed pattern.[***]
> ...
>>
>> [**] Probably a bit cryptic as well, though I simply derived it
>> from another algorithm I suggested a couple years ago to squeeze
>> multiple empty lines that separate text blocks to a single empty
>> line: awk 'NF,!NF'
>
> This reminds me of a lecture at a Seminar given by one of the profs
> here.
>
> "I gave a seminar 14 years ago on this topic, and I assume you all
> remember that."

Sorry, it was meant as: "If you understand the simpler form it's easy
to derive the a little bit more complex form." (i.e. an explanation
how I came to that code pattern).

> Yes, it is crytptic. Could you please expand?

Sure. A condition x,y is a range pattern, it executes the action block
(here non is given, so the default print $0 becomes executed),
starting from a record where x is true until (and including) a record
where y is true.

NF,!NF thus means (since NF means a blank line), start from any line
with visible input until (and including) a line that is blank. All
subsequent blank lines will not the printed since the next matching
pattern again start at a non-blank line.

The transposition to the new code is now easier to understand, I think.
$0!=p it starts printing with lines that don't match the pattern, and
continues until the first occurrence of the pattern ($0==p). The next
block starts again on the line that does not match the patter, thus it
skips additional patterns directly after the first one found.

Janis

Re: delete one of two consecutive line

<s8mpqn$7m0$2@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3865&group=comp.unix.shell#3865

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Thu, 27 May 2021 02:40:55 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 52
Message-ID: <s8mpqn$7m0$2@news-1.m-online.net>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8ma2l$31g$1@news-1.m-online.net> <s8mkl1$2g8$1@dont-email.me>
<s8mpmf$7m0$1@news-1.m-online.net>
NNTP-Posting-Host: 2001:a61:252a:da01:c904:461f:2bcc:f696
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1622076055 7872 2001:a61:252a:da01:c904:461f:2bcc:f696 (27 May 2021 00:40:55 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Thu, 27 May 2021 00:40:55 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <s8mpmf$7m0$1@news-1.m-online.net>
 by: Janis Papanagnou - Thu, 27 May 2021 00:40 UTC

On 27.05.2021 02:38, Janis Papanagnou wrote:
> On 27.05.2021 01:12, William Unruh wrote:
>> On 2021-05-26, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>> On 26.05.2021 07:01, Harry wrote:
>> ...
>>> Just for a variant I want to provide another awk approach[**]
>>>
>>> awk -v p='<?xml version="1.0"?>' '$0!=p, $0==p'
>>>
>>> which has the property to keep only one of multiple (2+) and
>>> only consecutive lines matching the passed pattern.[***]
>> ...
>>>
>>> [**] Probably a bit cryptic as well, though I simply derived it
>>> from another algorithm I suggested a couple years ago to squeeze
>>> multiple empty lines that separate text blocks to a single empty
>>> line: awk 'NF,!NF'
>>
>> This reminds me of a lecture at a Seminar given by one of the profs
>> here.
>>
>> "I gave a seminar 14 years ago on this topic, and I assume you all
>> remember that."
>
> Sorry, it was meant as: "If you understand the simpler form it's easy
> to derive the a little bit more complex form." (i.e. an explanation
> how I came to that code pattern).
>
>> Yes, it is crytptic. Could you please expand?
>
> Sure. A condition x,y is a range pattern, it executes the action block
> (here non is given, so the default print $0 becomes executed),
> starting from a record where x is true until (and including) a record
> where y is true.
>
> NF,!NF thus means (since NF means a blank line), start from any line

Should have been: (since NF means a non-blank line)

> with visible input until (and including) a line that is blank. All
> subsequent blank lines will not the printed since the next matching
> pattern again start at a non-blank line.
>
> The transposition to the new code is now easier to understand, I think.
> $0!=p it starts printing with lines that don't match the pattern, and
> continues until the first occurrence of the pattern ($0==p). The next
> block starts again on the line that does not match the patter, thus it
> skips additional patterns directly after the first one found.
>
> Janis
>

No fields is not necessarily an empty line (Was: delete one of two consecutive line)

<s8mqof$1cos1$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3866&group=comp.unix.shell#3866

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: No fields is not necessarily an empty line (Was: delete one of two consecutive line)
Date: Thu, 27 May 2021 00:56:47 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s8mqof$1cos1$1@news.xmission.com>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com> <s8mkl1$2g8$1@dont-email.me> <s8mpmf$7m0$1@news-1.m-online.net> <s8mpqn$7m0$2@news-1.m-online.net>
Injection-Date: Thu, 27 May 2021 00:56:47 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1467265"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Thu, 27 May 2021 00:56 UTC

In article <s8mpqn$7m0$2@news-1.m-online.net>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>> NF,!NF thus means (since NF means a blank line), start from any line
>
>Should have been: (since NF means a non-blank line)

Of course, a true nitpicker will point out that a line consisting only of
(a non-zero number of) spaces and/or tabs is not blank but will have NF==0.

If this concerns you, you could use "length" instead of "NF":

length,!length

Note: Gawk (the only AWK anyone who doesn't have access to TAWK should ever
use) supports this form of "length"; not sure which others do.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Cancer

Re: delete one of two consecutive line

<s8msp5$7cc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3867&group=comp.unix.shell#3867

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Thu, 27 May 2021 01:31:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <s8msp5$7cc$1@dont-email.me>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8ma2l$31g$1@news-1.m-online.net> <s8mkl1$2g8$1@dont-email.me>
<s8mpmf$7m0$1@news-1.m-online.net>
Injection-Date: Thu, 27 May 2021 01:31:17 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8c09b737a0d77987b2e1486612293a98";
logging-data="7564"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/U54Ky4jxdDk+nyNOiyFV4"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:EYRnXpFn3RAm0oH1oYnY/h19KyI=
 by: William Unruh - Thu, 27 May 2021 01:31 UTC

On 2021-05-27, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> On 27.05.2021 01:12, William Unruh wrote:
>> Yes, it is crytptic. Could you please expand?
....
>
> Sure. A condition x,y is a range pattern, it executes the action block
> (here non is given, so the default print $0 becomes executed),
> starting from a record where x is true until (and including) a record
> where y is true.

OK, makes sense. I had not come across that .
Thanks for the explanation.

Re: No fields is not necessarily an empty line (Was: delete one of two consecutive line)

<s8mt4o$8mp$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3868&group=comp.unix.shell#3868

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: No fields is not necessarily an empty line (Was: delete one of
two consecutive line)
Date: Thu, 27 May 2021 03:37:28 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 33
Message-ID: <s8mt4o$8mp$1@news-1.m-online.net>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8mkl1$2g8$1@dont-email.me> <s8mpmf$7m0$1@news-1.m-online.net>
<s8mpqn$7m0$2@news-1.m-online.net> <s8mqof$1cos1$1@news.xmission.com>
NNTP-Posting-Host: 2001:a61:252a:da01:c904:461f:2bcc:f696
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1622079448 8921 2001:a61:252a:da01:c904:461f:2bcc:f696 (27 May 2021 01:37:28 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Thu, 27 May 2021 01:37:28 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <s8mqof$1cos1$1@news.xmission.com>
 by: Janis Papanagnou - Thu, 27 May 2021 01:37 UTC

On 27.05.2021 02:56, Kenny McCormack wrote:
> In article <s8mpqn$7m0$2@news-1.m-online.net>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>>> NF,!NF thus means (since NF means a blank line), start from any line
>>
>> Should have been: (since NF means a non-blank line)
>
> Of course, a true nitpicker will point out that a line consisting only of
> (a non-zero number of) spaces and/or tabs is not blank but will have NF==0.

I deliberately used the words blank/non-blank to distinguish it from
empty/non-empty. Any blank/tab-character makes the line non-empty but
it still appears to be "blank", thus visually separating text blocks.
In the given case NF,!NF any accidentally typed blank or tab should
be considered like an empty line. (There may be other cases where it
might be desired to assume a different semantics, but (to me) in case
of blank lines this seemed more appropriate.)

>
> If this concerns you, you could use "length" instead of "NF":
>
> length,!length

This would not fit with the semantics I had in mind. Application cases,
interpretations, and opinions may differ, of course.

Janis

> Note: Gawk (the only AWK anyone who doesn't have access to TAWK should ever
> use) supports this form of "length"; not sure which others do.
>

Re: delete one of two consecutive line

<20210527112849.11eeebc6@nx-74205>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3869&group=comp.unix.shell#3869

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: comp.unix.shell
Subject: Re: delete one of two consecutive line
Date: Thu, 27 May 2021 11:28:49 +0200
Organization: A noiseless patient Strider
Lines: 27
Message-ID: <20210527112849.11eeebc6@nx-74205>
References: <1c8550b2-87db-4eee-8793-68cf9c209df5n@googlegroups.com>
<s8ma2l$31g$1@news-1.m-online.net>
<s8mkl1$2g8$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="3c90e0e2fb78b0dba063f742706b0388";
logging-data="29123"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19evOqgQub5QhL7md9jaP05"
Cancel-Lock: sha1:dH1gQUMujxAj8+m2Q0MK2DMo7+M=
X-Newsreader: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Aragorn - Thu, 27 May 2021 09:28 UTC

On 26.05.2021 at 23:12, William Unruh scribbled:

> This reminds me of a lecture at a Seminar given by one of the profs
> here.
>
> "I gave a seminar 14 years ago on this topic, and I assume you all
> remember that."

I had one that was even worse, in my freshman year of Applied
Information Technology. He was a military officer with the rank of
Major (and later Colonel) who was teaching math at civilian colleges.

"I'm not going to explain what's on the next 30 pages of your
course because you've all seen that stuff in high school last year."

Later on I discreetly told him that my graduation from high school was
11 years ago, and that I had in the meantime been to college in a
completely unrelated direction, then put in my conscription duty in the
military and then had several also unrelated jobs before deciding
to go back to college in order to study IT.

He didn't know what to say. Oopsie.

--
With respect,
= Aragorn =

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor