Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You will be advanced socially, without any special effort on your part.


comp / comp.unix.shell / Re: a sed question

SubjectAuthor
* a sed questionSalvador Mirzo
+- Re: a sed questionJohn-Paul Stewart
+* Re: a sed questionRalf Damaschke
|`* Re: a sed questionSalvador Mirzo
| `* Re: a sed questionRalf Damaschke
|  `* Re: a sed questionKenny McCormack
|   `* Re: a sed questionRalf Damaschke
|    `* Re: a sed questionKaz Kylheku
|     +* sed... (Was: a sed question)Kenny McCormack
|     |`* Re: sed... (Was: a sed question)Kaz Kylheku
|     | +* Re: sed... (Was: a sed question)Janis Papanagnou
|     | |`* Re: sed... (Was: a sed question)Janis Papanagnou
|     | | `* Re: sed...Keith Thompson
|     | |  `- Re: sed...Janis Papanagnou
|     | `* Re: sed... (Was: a sed question)Lars Poulsen
|     |  `- Re: sed... (Was: a sed question)Kaz Kylheku
|     +- Re: a sed questionJanis Papanagnou
|     `- Re: a sed questionRalf Damaschke
+* Re: a sed questionJanis Papanagnou
|+* Checking for right # of args in a shell script (Was: a sed question)Kenny McCormack
||`* Re: Checking for right # of args in a shell script (Was: a sed question)Janis Papanagnou
|| `- Re: Checking for right # of args in a shell script (Was: a sed question)Kenny McCormack
|+* Re: a sed questionSalvador Mirzo
||+* Re: a sed questionJanis Papanagnou
|||`* Re: a sed questionKeith Thompson
||| `* Re: a sed questionJanis Papanagnou
|||  +* Re: a sed questionKeith Thompson
|||  |`- Re: a sed questionJanis Papanagnou
|||  `* Re: a sed questionLawrence D'Oliveiro
|||   `- Re: a sed questionJanis Papanagnou
||+* Re: a sed questionAndy Walker
|||+- Re: a sed questionJanis Papanagnou
|||`* Re: a sed questionSalvador Mirzo
||| `- Re: a sed questionJanis Papanagnou
||`- Re: a sed questionHelmut Waitzmann
|`* Re: a sed questionOrdatious
| `- Re: a sed questionJanis Papanagnou
`* Re: a sed questionEd Morton
 `* Re: a sed questionLawrence D'Oliveiro
  +* Re: a sed questionJanis Papanagnou
  |`* Re: a sed questionLawrence D'Oliveiro
  | +* Re: a sed questionKeith Thompson
  | |`* Re: a sed questionLawrence D'Oliveiro
  | | `* Re: a sed questionKeith Thompson
  | |  `* Re: a sed questionLawrence D'Oliveiro
  | |   `* Re: a sed questionKeith Thompson
  | |    `* Re: a sed questionEric Pozharski
  | |     `* Re: a sed questionKenny McCormack
  | |      +- Re: a sed questionKaz Kylheku
  | |      `- Re: a sed questionEric Pozharski
  | `- Re: a sed questionJanis Papanagnou
  +- Re: a sed questionKenny McCormack
  +- Re: a sed questionKaz Kylheku
  `* Re: a sed questionEd Morton
   +- How to solve The Miracle (was Re: a sed question)Janis Papanagnou
   `* Re: a sed questionLawrence D'Oliveiro
    +* Re: a sed questionKeith Thompson
    |`- Re: a sed questionLawrence D'Oliveiro
    `* Re: a sed questionEd Morton
     +- Dealing with four-year-olds... (Was: a sed question)Kenny McCormack
     `* Re: a sed questionLawrence D'Oliveiro
      `* Re: a sed questionKaz Kylheku
       `- Arguing with a four-year-old (Was: a sed question)Kenny McCormack

Pages:123
Subject: Re: a sed question
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 21 Dec 2024 21:09 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 21:09:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <vk7ar2$7g01$4@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 21 Dec 2024 22:09:55 +0100 (CET)
Injection-Info: dont-email.me; posting-host="13a42d5f937e341e3a688a49c45bb4c8";
logging-data="245761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Wa+pj6+ttfw1ffT6l8clP"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:BLHiAOEnsTMFxnE2ISqfHcylxjc=
View all headers

On Sat, 21 Dec 2024 08:13:52 -0600, Ed Morton wrote:

> for anything else you should just use awk ...

If you want to suggest Awk, you might as well use Perl. That does
everything Awk does, just as concisely, and plenty more besides.

Subject: Re: a sed question
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sat, 21 Dec 2024 21:41 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 13:41:22 -0800
Organization: None to speak of
Lines: 41
Message-ID: <87bjx4ww71.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 21 Dec 2024 22:41:23 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2da3a0ffc775f005e8221f105190c671";
logging-data="252352"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uunq2qYrU/rmDL+Q2S4tb"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:+Ukv8Ve2iCHRoXpYrwlfUhv9kHA=
sha1:Runjw9qLe4E7KmjSnUNE5VEgo7I=
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 21.12.2024 13:17, Salvador Mirzo wrote:
[...]
> As previously mentioned, 'sed' might not be the best choice for
> developing such scripts; you might want to consider to learn 'awk'.
>
>> $ git log --oneline | head -1 | awk '{print $1}'
>> 2566d31
>
> With Awk you don't need 'head', it can be done like this
>
> $ git log --oneline | awk 'NR==1 {print $1}'
>
> (For long input files you may want an early exit
> ...| awk 'NR==1 { print $1 ; exit(0) }'
> but that just as an aside.)
[...]

This raises another issue: it's often possible to replace a command in a
pipeline that filters output with an option to the command that does the
same thing. There's no general rule for how to do this, since different
commands do things differently, but for the example above:

git log --oneline -n 1 | awk '{print $1}'

or even:

git log -n 1 --format=%h

I haven't memorized the "--format" option, so I don't generally us it in
ad-hoc one-liners, but I do use it in scripts. Note both of the above
commands avoid generating the entire list of log entries, which could
save significant time on a large repo.

Using unnecessary commands in pipelines is Mostly Harmless, but IMHO
it's good to think about how to do things more efficiently. See also
"Useless use of cat" (UUOC).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: sed... (Was: a sed question)
From: Lars Poulsen
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 21 Dec 2024 21:46 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lars@cleo.beagle-ears.com (Lars Poulsen)
Newsgroups: comp.unix.shell
Subject: Re: sed... (Was: a sed question)
Date: Sat, 21 Dec 2024 21:46:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <slrnvmedpg.26aoh.lars@cleo.beagle-ears.com>
References: <874j304vv3.fsf@example.com> <vk3orv$1ut71$1@news.xmission.com>
<lsmfo5Ffor3U1@mid.individual.net> <20241220184059.820@kylheku.com>
<vk5d3b$1vn8e$1@news.xmission.com> <20241220195517.951@kylheku.com>
Injection-Date: Sat, 21 Dec 2024 22:46:24 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7d1529f084e77bd01b32ce765f1043df";
logging-data="257228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IOT1jI74L60tVN1OcY8FdTRqH+6/QnbQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:5o1qJ+qv7+mYsLHqhMpsBXZjj8k=
View all headers

In article <20241220184059.820@kylheku.com>,
Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>> The goal of writing in sed is not to solve the problem, and to
>> communicate with
>> future users of the program so that they can adapt it to changing needs; the
>> goal is to puzzle out what it takes to solve it in Sed, and to show: "Hey,
>> look, I did this in Sed! Isn't it amazing? (And, by extension, aren't I?)"

Just like APL.
- "can you figure out what this one-line program does?"
- "can you think of a way to do this in fewer characters?"

Subject: Re: sed...
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sat, 21 Dec 2024 22:23 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: sed...
Date: Sat, 21 Dec 2024 14:23:49 -0800
Organization: None to speak of
Lines: 26
Message-ID: <874j2wwu8a.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk3orv$1ut71$1@news.xmission.com>
<lsmfo5Ffor3U1@mid.individual.net> <20241220184059.820@kylheku.com>
<vk5d3b$1vn8e$1@news.xmission.com> <20241220195517.951@kylheku.com>
<vk6jsu$33b0$2@dont-email.me> <vk6qcp$4hot$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 21 Dec 2024 23:23:50 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2da3a0ffc775f005e8221f105190c671";
logging-data="252352"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19P/L2xeC816x5YQj/E7nEQ"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:OQVjWY+6+2EGEfDxkiP3oewGvCE=
sha1:Hff9i928jHMNdBD7n/Oyqo44uU8=
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 21.12.2024 15:38, Janis Papanagnou wrote:
>> On 21.12.2024 04:57, Kaz Kylheku wrote:
>>>
>>> Sometimes that puzzled out stuff people do in their spare time is really cool!
>>>
>>> This just appeared on HackerNews:
>>>
>>> https://github.com/izabera/pseudo3d
>>>
>>> A raycast first-person maze navigator, written in Bash.
>>
>> Wasn't there a similar code in Awk mentioned some time ago?
>
> I found it (fps.awk) on my file system; ~650 LOC - too long to post?
> (I see it uses some GNU Awk features.)
> To support searches for it, it says: #Copyright (c) 2016 Fedor Kalugin

https://github.com/patsie75/awk-fps

I don't think this is the same thing; there's no copyright and the file
names don't match.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: sed...
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 21 Dec 2024 23:33 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: sed...
Date: Sun, 22 Dec 2024 00:33:58 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vk7j97$95do$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk3orv$1ut71$1@news.xmission.com>
<lsmfo5Ffor3U1@mid.individual.net> <20241220184059.820@kylheku.com>
<vk5d3b$1vn8e$1@news.xmission.com> <20241220195517.951@kylheku.com>
<vk6jsu$33b0$2@dont-email.me> <vk6qcp$4hot$1@dont-email.me>
<874j2wwu8a.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 Dec 2024 00:34:00 +0100 (CET)
Injection-Info: dont-email.me; posting-host="01087a4c372056a264078a83b087f742";
logging-data="300472"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hQXsVnqZTgQ3z4vDtGhNo"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:PRA+Jt5DZGKDmohRLKE/xpkustE=
In-Reply-To: <874j2wwu8a.fsf@nosuchdomain.example.com>
View all headers

On 21.12.2024 23:23, Keith Thompson wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 21.12.2024 15:38, Janis Papanagnou wrote:
>>> On 21.12.2024 04:57, Kaz Kylheku wrote:
>>>>
>>>> Sometimes that puzzled out stuff people do in their spare time is really cool!
>>>>
>>>> This just appeared on HackerNews:
>>>>
>>>> https://github.com/izabera/pseudo3d
>>>>
>>>> A raycast first-person maze navigator, written in Bash.
>>>
>>> Wasn't there a similar code in Awk mentioned some time ago?
>>
>> I found it (fps.awk) on my file system; ~650 LOC - too long to post?
>> (I see it uses some GNU Awk features.)
>> To support searches for it, it says: #Copyright (c) 2016 Fedor Kalugin
>
> https://github.com/patsie75/awk-fps

It's something different. - But thanks for the link!

> I don't think this is the same thing; there's no copyright and the file
> names don't match.

I don't know the original filename; I might have changed it on download.

I've put the source version I meant here: volatile.gridbug.de/fps.awk

Janis

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 21 Dec 2024 23:50 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 00:50:45 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <vk7k8m$9b25$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
<87bjx4ww71.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 Dec 2024 00:50:49 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9629fd46d3ef03abd119c82e77c4bd73";
logging-data="306245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HRN9Lrp8XH7SDWJ+U0HPi"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:c6TFqD3x1DJi9jr+cne3OJyZztE=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <87bjx4ww71.fsf@nosuchdomain.example.com>
View all headers

On 21.12.2024 22:41, Keith Thompson wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 21.12.2024 13:17, Salvador Mirzo wrote:
> [...]
>> As previously mentioned, 'sed' might not be the best choice for
>> developing such scripts; you might want to consider to learn 'awk'.
>>
>>> $ git log --oneline | head -1 | awk '{print $1}'
>>> 2566d31
>>
>> With Awk you don't need 'head', it can be done like this
>>
>> $ git log --oneline | awk 'NR==1 {print $1}'
>>
>> (For long input files you may want an early exit
>> ...| awk 'NR==1 { print $1 ; exit(0) }'
>> but that just as an aside.)
> [...]
>
> This raises another issue: it's often possible to replace a command in a
> pipeline that filters output with an option to the command that does the
> same thing. There's no general rule for how to do this, since different
> commands do things differently, but for the example above:
>
> git log --oneline -n 1 | awk '{print $1}'

Yes. - I just used the OP's presented sample to show the principle
(and not make up an own example to illustrate the case).

In practice it goes even farther; with Awk typical pipeline command
sequences that use utilities like cat, head, tail, grep, cut, sed,
tr, wc, seq, tee, etc. can typically all be represented and combined
by Awk. There's also the additional effect that if you want to pass
some context information from a tool near the front of the pipe to
a tool near the other end it's possible to maintain arbitrary state
information within the Awk program.

Of course, if you can _reduce_ the amount of data at an early stage
(like in your 'git -n 1' sample) the earlier the better! (My 'git',
BTW, doesn't seem to support an option '-n'; which might be another
reason to let a standard tool like Awk do the task for which it has
been defined, text-processing.)

>
> or even:
>
> git log -n 1 --format=%h
>
> I haven't memorized the "--format" option, so I don't generally us it in
> ad-hoc one-liners, but I do use it in scripts. Note both of the above
> commands avoid generating the entire list of log entries, which could
> save significant time on a large repo.
>
> Using unnecessary commands in pipelines is Mostly Harmless, but IMHO
> it's good to think about how to do things more efficiently. See also
> "Useless use of cat" (UUOC).

Janis

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 00:02 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 01:02:03 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vk7kts$9evn$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 Dec 2024 01:02:05 +0100 (CET)
Injection-Info: dont-email.me; posting-host="01087a4c372056a264078a83b087f742";
logging-data="310263"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i+HE3Eg/xm0j8MQ3Uxy1t"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:cJoX0rMcK99tDhFUBCGNuIN5UW8=
In-Reply-To: <vk7ar2$7g01$4@dont-email.me>
X-Enigmail-Draft-Status: N1110
View all headers

On 21.12.2024 22:09, Lawrence D'Oliveiro wrote:
> On Sat, 21 Dec 2024 08:13:52 -0600, Ed Morton wrote:
>
>> for anything else you should just use awk ...

(I wouldn't formulate it that way. - Just for the record.)

> If you want to suggest Awk, you might as well use Perl.

(Unfortunately no.)

> That does
> everything Awk does, just as concisely, and plenty more besides.

(Features are not the whole story.)

The advantage of Awk is that it's standard on Unix systems and can
thus also be used in restricted professional environments (that are
not uncommon as I experienced).

There's yet more advantages, like (compared to Perl) legible syntax
and being a terse language that you can quickly learn (and master).
(I've elsethread mentioned R.Loui's examination of learning curves;
he compared Perl and Awk in that respect, and Perl was, expectedly,
much worse concerning that.)

I know you're a fan of Perl, so I finish my post with the comment
that Perl has other strengths. (Or Python, or <insert your favorite
tool here>, etc.)

Janis

Subject: Re: a sed question
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sun, 22 Dec 2024 00:26 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 16:26:59 -0800
Organization: None to speak of
Lines: 24
Message-ID: <87zfkov9yk.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
<87bjx4ww71.fsf@nosuchdomain.example.com>
<vk7k8m$9b25$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 22 Dec 2024 01:27:21 +0100 (CET)
Injection-Info: dont-email.me; posting-host="05490bf84a23842e58914ee4885380df";
logging-data="317765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19N8Lm+2Hbos52wLGtdRkar"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:1D50IrI5dKszZGGCWn0I2BpsN9Y=
sha1:3Ap/h6JECnFZboiVaQ834snuUFw=
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
[...]
> Of course, if you can _reduce_ the amount of data at an early stage
> (like in your 'git -n 1' sample) the earlier the better! (My 'git',
> BTW, doesn't seem to support an option '-n'; which might be another
> reason to let a standard tool like Awk do the task for which it has
> been defined, text-processing.)

What version of git are you using?

Note that "-n 1" is an argument to "git log", not to "git".
"git -n 1" is an error, as is "git -n 1 log". "git log -n 1" should work.

The "-n" option can also be given as just the number:

git log -1

or as a long option:

git log --max-count=1

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: a sed question
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 00:28 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 00:28:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <vk7meu$9jp7$2@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 01:28:15 +0100 (CET)
Injection-Info: dont-email.me; posting-host="64490d56db4080936801cde0bc760236";
logging-data="315175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19TF3cR9ZUvii6e6NS2ohto"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:TxQcISGuMo589VqDp4gOI3CVKKE=
View all headers

On Sun, 22 Dec 2024 01:02:03 +0100, Janis Papanagnou wrote:

> The advantage of Awk is that it's standard on Unix systems ...

On my Debian system:

ldo@theon:~> apt-cache rdepends gawk | wc -l
89
ldo@theon:~> apt-cache rdepends perl | wc -l
1121

Let’s just say, you’re more likely to find Perl than Awk on a Linux
system ...

Subject: Re: a sed question
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 00:31 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 00:31:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <vk7mk4$9jp7$3@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
<87bjx4ww71.fsf@nosuchdomain.example.com> <vk7k8m$9b25$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 01:31:01 +0100 (CET)
Injection-Info: dont-email.me; posting-host="64490d56db4080936801cde0bc760236";
logging-data="315175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HUU6hQQAMn6zQ1qEvAwLv"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:neUmq463XFTwQZCddSd8QJUskz8=
View all headers

On Sun, 22 Dec 2024 00:50:45 +0100, Janis Papanagnou wrote:

> In practice it goes even farther; with Awk typical pipeline command
> sequences that use utilities like cat, head, tail, grep, cut, sed, tr,
> wc, seq, tee, etc. can typically all be represented and combined by Awk.

Another counterexample to the hoary old “do one thing and do it well”
trope ...

Subject: Re: a sed question
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sun, 22 Dec 2024 00:36 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 16:36:32 -0800
Organization: None to speak of
Lines: 23
Message-ID: <87v7vcv9in.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 01:36:34 +0100 (CET)
Injection-Info: dont-email.me; posting-host="05490bf84a23842e58914ee4885380df";
logging-data="317765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VaFs5qt/00+dYHl5mF/zz"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:CmpmViSgq3vSu6kI149DPYP5ew8=
sha1:PEdspO6i6JKouDPMjm9YuCzdXM8=
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Sun, 22 Dec 2024 01:02:03 +0100, Janis Papanagnou wrote:
>> The advantage of Awk is that it's standard on Unix systems ...
>
> On my Debian system:
>
> ldo@theon:~> apt-cache rdepends gawk | wc -l
> 89
> ldo@theon:~> apt-cache rdepends perl | wc -l
> 1121
>
> Let’s just say, you’re more likely to find Perl than Awk on a Linux
> system ...

I don't see how your conclusion follows from the data (of how many
packages depend on gawk and perl, respectively). I'd be surprised to
see *any* Linux distribution (other than small embedded systems) that
doesn't include awk (either gawk or mawk, or even busybox awk) by
default.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 00:41 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 01:41:46 +0100
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <vk7n8a$9okb$2@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
<87bjx4ww71.fsf@nosuchdomain.example.com> <vk7k8m$9b25$1@dont-email.me>
<87zfkov9yk.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 Dec 2024 01:41:47 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9629fd46d3ef03abd119c82e77c4bd73";
logging-data="320139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SAKmm/5QeFF3D+SDxubHJ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:4VJOTKsFNislXn8+StOQGdNXRRE=
In-Reply-To: <87zfkov9yk.fsf@nosuchdomain.example.com>
View all headers

On 22.12.2024 01:26, Keith Thompson wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> [...]
>> Of course, if you can _reduce_ the amount of data at an early stage
>> (like in your 'git -n 1' sample) the earlier the better! (My 'git',
>> BTW, doesn't seem to support an option '-n'; which might be another
>> reason to let a standard tool like Awk do the task for which it has
>> been defined, text-processing.)
>
> What version of git are you using?
>
> Note that "-n 1" is an argument to "git log", not to "git".

Stupid me! - Of course. I need some coffee...

Janis

> [...]

Subject: Re: a sed question
From: Ralf Damaschke
Newsgroups: comp.unix.shell
Organization: C.H.A.O.S.
Date: Sun, 22 Dec 2024 00:43 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rwspam@gmx.de (Ralf Damaschke)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: 22 Dec 2024 00:43:40 GMT
Organization: C.H.A.O.S.
Lines: 24
Message-ID: <lsp5lsFsql5U1@mid.individual.net>
References: <874j304vv3.fsf@example.com> <lshab3Fk6t3U1@mid.individual.net>
<87wmfv27yy.fsf@example.com> <lsjtj8F2r8aU1@mid.individual.net>
<vk3orv$1ut71$1@news.xmission.com> <lsmfo5Ffor3U1@mid.individual.net>
<20241220184059.820@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net UcmdoybqLBHMOlAHGn44Ng0KpHAenWZOYmIkvI6H+Q73triDnx
Cancel-Lock: sha1:BeQzV/vAGff8RG6Qt6HppbJZrVY= sha256:O3yrJJK0gJaggQ1huXy4n4hPvXjJBDfkqE3slDJ7lkw=
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
View all headers

Kaz Kylheku wrote:
> On 2024-12-21, Ralf Damaschke <rwspam@gmx.de> wrote:
>> Simply because you cannot imagine how to use it? No!
>
> He explained the "because", in the immediately following text that you
> snipped:

I don't agree with his explanation.

> KMC> Seriously, the above looks like gobbledegook compared to the
> equivalent in
> KMC> AWK (or some other normal scripting langugae). "sed" looks like
> Intercal
> KMC> (once you get beyond s/foo/bar/g).

For many people C looks like gobbledegook, too.

> KMC> I'm sure that whatever it is that OP is trying to do, it could be
> easily
> KMC> translated to (say) AWK and look much nicer.

That's probably true. I often prefer awk too, but that is not sufficient
to state "don't use sed for anything beyond the s/foo/bar/g stage". There
have been quite some tasks where I used sed.

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 01:06 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 02:06:23 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <vk7omn$a1rs$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<87ed21xmb3.fsf@example.com> <vk6mam$3lsj$1@dont-email.me>
<87bjx4ww71.fsf@nosuchdomain.example.com> <vk7k8m$9b25$1@dont-email.me>
<vk7mk4$9jp7$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 02:06:31 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9629fd46d3ef03abd119c82e77c4bd73";
logging-data="329596"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LxsFCSmCEpYBOigK6bG54"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:64/ndi7e5+F3XwSeSfDUpcXcZ9w=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vk7mk4$9jp7$3@dont-email.me>
View all headers

On 22.12.2024 01:31, Lawrence D'Oliveiro wrote:
> On Sun, 22 Dec 2024 00:50:45 +0100, Janis Papanagnou wrote:
>
>> In practice it goes even farther; with Awk typical pipeline command
>> sequences that use utilities like cat, head, tail, grep, cut, sed, tr,
>> wc, seq, tee, etc. can typically all be represented and combined by Awk.
>
> Another counterexample to the hoary old “do one thing and do it well”
> trope ...

I'm not quite sure what you're aiming at with your statement.

My own stance on that is that this "do one thing and do it well”
is okay in principle, but it's also no dogma for me. - It still
holds in many places.

There's some tools, though, that stuff all sorts of functions
into its own feature set that aren't appropriate. (I had a good
example but it evades me at the moment. - Where's my coffee?! -
Anyway, you may have observed your own examples.)

For the given discussion, Awk's "one thing" is text-processing.
OTOH, 'cut', for example, does one [very primitive] thing, but
it _completely_ *fails* to do it well.

The point is that a pipeline is a very restricted way of data
processing and it quickly turns out in non-trivial applications
that you have your data-processing task split into "elementary
operations" that you clumsily have to glue together with shell,
and some things just can't be reasonably done that way.

I still use 'head' or 'tail' (or even 'cat') if I want to get
a quick look onto some data - I certainly don't use Awk for
that. But as soon as many of your "elementary operations" get
combined (which often can be anticipated) using a better tool
might be appropriate (Awk, Perl, Python, whatever one thinks
fits best).

It's good that we have tools like, e.g., 'sort'. And I'm not
very excited about, say, GNU Awk's various sort() functions.
(But they might come in handy in cases.)

In short; it's good to use the appropriate tools, notice if
tools get worse at certain jobs, and change if necessary.

Janis

Subject: Re: a sed question
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Sun, 22 Dec 2024 01:09 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 01:09:23 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vk7os3$20rrk$1@news.xmission.com>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me> <vk7ar2$7g01$4@dont-email.me>
Injection-Date: Sun, 22 Dec 2024 01:09:23 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2125684"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vk7ar2$7g01$4@dont-email.me>,
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>On Sat, 21 Dec 2024 08:13:52 -0600, Ed Morton wrote:
>
>> for anything else you should just use awk ...
>
>If you want to suggest Awk, you might as well use Perl. That does
>everything Awk does, just as concisely, and plenty more besides.

So does Intercal. Point, set match.

--
There are many self-professed Christians who seem to think that because
they believe in Jesus' sacrifice they can reject Jesus' teachings about
how we should treat others. In this country, they show that they reject
Jesus' teachings by voting for Republicans.

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 01:22 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 02:22:18 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vk7pkb$a6l9$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 02:22:20 +0100 (CET)
Injection-Info: dont-email.me; posting-host="9629fd46d3ef03abd119c82e77c4bd73";
logging-data="334505"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MkTl9M/gKzG2qiP5PpJ5h"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:FRJiHMwuPGDMy0ZK/sP4ta247+U=
In-Reply-To: <vk7meu$9jp7$2@dont-email.me>
X-Enigmail-Draft-Status: N1110
View all headers

On 22.12.2024 01:28, Lawrence D'Oliveiro wrote:
> On Sun, 22 Dec 2024 01:02:03 +0100, Janis Papanagnou wrote:
>
>> The advantage of Awk is that it's standard on Unix systems ...
>
> On my Debian system:
>
> ldo@theon:~> apt-cache rdepends gawk | wc -l
> 89
> ldo@theon:~> apt-cache rdepends perl | wc -l
> 1121
>
> Let’s just say, you’re more likely to find Perl than Awk on a Linux
> system ...

My comment was on Unix systems (not specifically Linux) and on
the Unix standards (POSIX).

Not sure what you read and understood where I wrote "standard".

Awk is demanded by POSIX, Perl isn't.

So on any standard conforming Unix you are guaranteed to *have*
a 'sh' (POSIX-shell) and an 'awk'. Moreover, even if you are
developing on a system with Perl, but will have to implement
(run) the software in a different environment, you may not be
allowed to install third party software (open or else) with it.

(One may not like such company policies but they are reality.)

Janis

Subject: Re: a sed question
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 01:52 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 01:52:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <vk7rdi$ae6m$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me> <87v7vcv9in.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 02:52:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="64490d56db4080936801cde0bc760236";
logging-data="342230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nFFfa5XBzmVv4e3ilavPE"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:Q3G1XOtDxml9f5wkH44F9dNGEzQ=
View all headers

On Sat, 21 Dec 2024 16:36:32 -0800, Keith Thompson wrote:

> I'd be surprised to
> see *any* Linux distribution (other than small embedded systems) that
> doesn't include awk (either gawk or mawk, or even busybox awk) by
> default.

The point being, it would likely be easier to remove Awk than to remove
Perl.

Subject: Re: a sed question
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sun, 22 Dec 2024 05:09 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 21:09:25 -0800
Organization: None to speak of
Lines: 16
Message-ID: <87r060uwvu.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me>
<87v7vcv9in.fsf@nosuchdomain.example.com>
<vk7rdi$ae6m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 06:09:28 +0100 (CET)
Injection-Info: dont-email.me; posting-host="05490bf84a23842e58914ee4885380df";
logging-data="523233"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bEvjHAMx/T6prcqSSUEAa"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:lx5ZOYRdmbkTuqEPt+9/UwaY31o=
sha1:N89oywP3YeTVFM/4CK885V/civA=
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Sat, 21 Dec 2024 16:36:32 -0800, Keith Thompson wrote:
>> I'd be surprised to
>> see *any* Linux distribution (other than small embedded systems) that
>> doesn't include awk (either gawk or mawk, or even busybox awk) by
>> default.
>
> The point being, it would likely be easier to remove Awk than to remove
> Perl.

Which is quite different from what you wrote, which was that "you’re
more likely to find Perl than Awk on a Linux system".

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: a sed question
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 05:56 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 05:56:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <vk89m1$gbta$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me> <87v7vcv9in.fsf@nosuchdomain.example.com>
<vk7rdi$ae6m$1@dont-email.me> <87r060uwvu.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 06:56:22 +0100 (CET)
Injection-Info: dont-email.me; posting-host="64490d56db4080936801cde0bc760236";
logging-data="536490"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bqf1WlYcd9RaljjFEWWuO"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:TAQB6DVxz+xcJUEemKG/D8I8w8U=
View all headers

On Sat, 21 Dec 2024 21:09:25 -0800, Keith Thompson wrote:

> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
>> On Sat, 21 Dec 2024 16:36:32 -0800, Keith Thompson wrote:
>>
>>> I'd be surprised to
>>> see *any* Linux distribution (other than small embedded systems) that
>>> doesn't include awk (either gawk or mawk, or even busybox awk) by
>>> default.
>>
>> The point being, it would likely be easier to remove Awk than to remove
>> Perl.
>
> Which is quite different from what you wrote, which was that "you’re
> more likely to find Perl than Awk on a Linux system".

You do know that Linux systems encourage customization, don’t you?

Subject: Re: a sed question
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Sun, 22 Dec 2024 06:55 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sat, 21 Dec 2024 22:55:01 -0800
Organization: None to speak of
Lines: 23
Message-ID: <87msgourzu.fsf@nosuchdomain.example.com>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me>
<87v7vcv9in.fsf@nosuchdomain.example.com>
<vk7rdi$ae6m$1@dont-email.me>
<87r060uwvu.fsf@nosuchdomain.example.com>
<vk89m1$gbta$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 22 Dec 2024 07:55:20 +0100 (CET)
Injection-Info: dont-email.me; posting-host="05490bf84a23842e58914ee4885380df";
logging-data="550362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qm0mn4EorLklH8UmyMS0p"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:rWxPkJHSnaWtrAbsaZWwoE2TALs=
sha1:lDkMJPvTxYjVq+edIO43OarqU9E=
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Sat, 21 Dec 2024 21:09:25 -0800, Keith Thompson wrote:
>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>> On Sat, 21 Dec 2024 16:36:32 -0800, Keith Thompson wrote:
>>>> I'd be surprised to
>>>> see *any* Linux distribution (other than small embedded systems) that
>>>> doesn't include awk (either gawk or mawk, or even busybox awk) by
>>>> default.
>>>
>>> The point being, it would likely be easier to remove Awk than to remove
>>> Perl.
>>
>> Which is quite different from what you wrote, which was that "you’re
>> more likely to find Perl than Awk on a Linux system".
>
> You do know that Linux systems encourage customization, don’t you?

I can no longer keep up with the rapid movement of the goalposts.
I see no point in continuing this discussion.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: a sed question
From: Ordatious
Newsgroups: comp.unix.shell
Organization: Easynews - www.easynews.com
Date: Sun, 22 Dec 2024 09:19 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx03.ams4.POSTED!not-for-mail
From: order@order.invalid (Ordatious)
Subject: Re: a sed question
Newsgroups: comp.unix.shell
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
MIME-Version: 1.0
x-no-archive: yes
User-Agent: Pan/0.161 (Chasiv Yar; 7e6f2f6)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 8
Message-ID: <%QQ9P.18710$M62.16479@fx03.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 22 Dec 2024 09:19:55 GMT
X-Received-Bytes: 895
View all headers

On Fri, 20 Dec 2024 15:55:12 +0100, Janis Papanagnou wrote:

> you may get subtle errors in future if you continue that habit.

For us newbies, do you have an example?

--
Order! Order in the group!

Subject: Re: a sed question
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 18:23 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 19:23:00 +0100
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <vk9le5$o2fo$1@dont-email.me>
References: <874j304vv3.fsf@example.com> <vk40gi$3g9sm$1@dont-email.me>
<%QQ9P.18710$M62.16479@fx03.ams4>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 Dec 2024 19:23:01 +0100 (CET)
Injection-Info: dont-email.me; posting-host="b3b1296be5022f5b9cedd89f7de9a436";
logging-data="788984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x6VSo39sV4O7+1+Swk9lN"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:82nPJ/C55P2wovA0K01lQg7vZ3c=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <%QQ9P.18710$M62.16479@fx03.ams4>
View all headers

On 22.12.2024 10:19, Ordatious wrote:
> On Fri, 20 Dec 2024 15:55:12 +0100, Janis Papanagnou wrote:
>
>> you may get subtle errors in future if you continue that habit.
>
> For us newbies, do you have an example?

(I had to look up what in my post you were referring to here...)

It was about -lt vs '<' in comparisons of strings and numbers
respectively. - And I had already answered that elsethread.

Depending on the actual value in a string variable you may get
_correct looking_ result for many values but since you're not
using the correct operator you "unexpectedly" may see errors
that you "can't explain".

The OP was comparing the number of arguments against a value
of 2 with the string comparison. Try (for example) the code

for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
do
set $@ $i
if [ $# '<' 2 ]
then echo "$# < 2"
else echo "$# >= 2"
fi
done

and observe the output

1 < 2
2 >= 2
3 >= 2
4 >= 2
5 >= 2
6 >= 2
7 >= 2
8 >= 2
9 >= 2
10 < 2
11 < 2
12 < 2
13 < 2
14 < 2
15 < 2
16 < 2
17 < 2
18 < 2
19 < 2
20 >= 2
21 >= 2
22 >= 2
23 >= 2
24 >= 2
25 >= 2
26 >= 2

So for "typical" argument numbers <=9 you get the correct result,
but once you have more arguments with this program, or if you
have wrongly used '<' in another program that expects "naturally"
more arguments than the OP's sample program you'll get erroneous
behavior (and might not be aware of that if you're used to using
'<').

It makes thus no sense to use the wrong operator only because it
*sometimes* works correctly even for numeric arguments.

HTH.

Janis

Subject: Re: a sed question
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 20:03 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Sun, 22 Dec 2024 20:03:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20241222114645.813@kylheku.com>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me>
Injection-Date: Sun, 22 Dec 2024 21:03:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ccd8ace10f73d1976dbd98bdbf28dd7f";
logging-data="818297"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vwknHYjVibePY9s8bpInuTK3XTjeu2g0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:M1KY/c1rs4npyctwzWGadk6YO0Q=
View all headers

On 2024-12-21, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Sat, 21 Dec 2024 08:13:52 -0600, Ed Morton wrote:
>
>> for anything else you should just use awk ...
>
> If you want to suggest Awk, you might as well use Perl. That does
> everything Awk does, just as concisely, and plenty more besides.

Perl certainly does not do everything that Awk does just as concisely.

The sigils on variable names alone make Perl one-liner solutions longer.

So do the extra command line options needed in order to get an Awk-like
implicit input processing loop.

For instance, deduplicate lines:

awk '!s[$0]++'

Larry Wall himself famously said something like "I still say awk
'{ print $1 }' a lot".

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: sed... (Was: a sed question)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 22 Dec 2024 21:22 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: sed... (Was: a sed question)
Date: Sun, 22 Dec 2024 21:22:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20241222131805.854@kylheku.com>
References: <874j304vv3.fsf@example.com> <vk3orv$1ut71$1@news.xmission.com>
<lsmfo5Ffor3U1@mid.individual.net> <20241220184059.820@kylheku.com>
<vk5d3b$1vn8e$1@news.xmission.com> <20241220195517.951@kylheku.com>
<slrnvmedpg.26aoh.lars@cleo.beagle-ears.com>
Injection-Date: Sun, 22 Dec 2024 22:22:18 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ccd8ace10f73d1976dbd98bdbf28dd7f";
logging-data="843345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bJtvuOYObEuLVUdoImwykeg6r9jI2Bx8="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:sZc+tnPoC0i889RIzFL5W8KpAm8=
View all headers

On 2024-12-21, Lars Poulsen <lars@cleo.beagle-ears.com> wrote:
> In article <20241220184059.820@kylheku.com>,
> Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>>> The goal of writing in sed is not to solve the problem, and to
>>> communicate with
>>> future users of the program so that they can adapt it to changing needs; the
>>> goal is to puzzle out what it takes to solve it in Sed, and to show: "Hey,
>>> look, I did this in Sed! Isn't it amazing? (And, by extension, aren't I?)"
>
> Just like APL.
> - "can you figure out what this one-line program does?"
> - "can you think of a way to do this in fewer characters?"

It's not quite so easy to casually dismiss APL, because if you look past
the reduction in character syntax, it has a powerful array processing
paradigm that made it unique at the time of its inception. APL programs
are actually short in the number of tokens and operations specified, not
just character count.

Sed is more like BrainF##### in just making things stupidly harder;
it's not a notation for something powerful under the hood.

A sed program won't necessarily be shorter than an Awk one. For instance
certainly not if it has to implement integer addition using regexps on
strings, where the Awk program just does a + b.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: a sed question
From: Eric Pozharski
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 23 Dec 2024 10:09 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.unix.shell
Subject: Re: a sed question
Date: Mon, 23 Dec 2024 10:09:49 +0000
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <slrnvmidnd.9vr.apple.universe@freight.zombinet>
References: <874j304vv3.fsf@example.com> <vk6if0$2n5s$1@dont-email.me>
<vk7ar2$7g01$4@dont-email.me> <vk7kts$9evn$1@dont-email.me>
<vk7meu$9jp7$2@dont-email.me> <87v7vcv9in.fsf@nosuchdomain.example.com>
<vk7rdi$ae6m$1@dont-email.me> <87r060uwvu.fsf@nosuchdomain.example.com>
<vk89m1$gbta$1@dont-email.me> <87msgourzu.fsf@nosuchdomain.example.com>
Injection-Date: Mon, 23 Dec 2024 11:33:06 +0100 (CET)
Injection-Info: dont-email.me; posting-host="45278dfd8b41f5cd797ef45f28384ee8";
logging-data="1233882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+q2lmmvRs10qO6Yt94V7C7"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:uNM5CTLDTo0qCKjT1WxFo4FL/mM=
View all headers

with <87msgourzu.fsf@nosuchdomain.example.com> Keith Thompson wrote:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Sat, 21 Dec 2024 21:09:25 -0800, Keith Thompson wrote:
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>>> On Sat, 21 Dec 2024 16:36:32 -0800, Keith Thompson wrote:

*SKIP* [ 8 lines 5 levels deep] # there isn't anything to see

> I can no longer keep up with the rapid movement of the goalposts. I
> see no point in continuing this discussion.

Point of this (and many others) discussion is to generate engagement.
Turns out, talking about lizard people doesn't ignite Usenet. Who knew.

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Pages:123

rocksolid light 0.9.8
clearnet tor