Re: "sed" question

Liste des GroupesRevenir à cl awk 
Sujet : Re: "sed" question
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.awk
Date : 09. Mar 2024, 21:49:43
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240309124320.907@kylheku.com>
References : 1 2 3 4 5 6
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
On 09.03.2024 17:52, Ed Morton wrote:
 About 20 or so years ago we had a discussion in this NG (which I'm not
going to search for now) and, shockingly, a consensus was reached that
we should encourage people to always write:
     '{$2="1-1"} 1'
 
>
I don't recall such a "consensus". If you want to avoid cryptic code
you'd rather write
>
      '{$2="1-1"; print}'
>
Don't you think?
I don't remember it either, but it's a no brainer that '$2=expr'
is incorrect if expr is arbitrary, and the intent is that
the implicit print is to be unconditionally invoked.
If expr is a nonblank, nonzero literal term, then the assignment
is obviously true and '$2=literal' as the entire program is a fine
idiom.
I don't agree with putting braces around it and adding 1, or explicit
print.
You are not then using Awk like it was meant to be.
When Awk was conceived, the authors peered into a crystal ball and saw
Perl. After the laughter died down, they got serious and made sure to
provide for idioms like:
  awk '!s[$0]++'
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
9 Mar 24 * Re: "sed" question12Christian Weisgerber
9 Mar 24 +* Re: "sed" question2Julieta Shem
9 Mar 24 i`- Re: "sed" question1gazelle@shell.xmission.com (Kenny McCormack)
9 Mar 24 +* Re: "sed" question8Ed Morton
9 Mar 24 i+* Re: "sed" question5Janis Papanagnou
9 Mar 24 ii+- Re: "sed" question1Kaz Kylheku
13 Mar 24 ii`* Re: "sed" question3Ed Morton
14 Mar 24 ii `* Re: "sed" question2Janis Papanagnou
14 Mar 24 ii  `- Re: "sed" question1Ed Morton
11 Mar 24 i`* Re: "sed" question2Mr. Man-wai Chang
11 Mar 24 i `- Re: "sed" question1Keith Thompson
9 Mar 24 `- Re: "sed" question1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal