Re: printing words without newlines?

Liste des Groupes 
Sujet : Re: printing words without newlines?
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : alt.comp.lang.awk comp.lang.awk
Date : 13. May 2024, 15:53:38
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <v1t9hi$u4lh$1@news.xmission.com>
References : 1 2
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <v1sdji$tofu$2@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
...
I guess this is what you actually want:
>
{ A[$1] = $2 }
END {
   len = length(A)
   for (i=1; i<=len; i++)
printf("%s%s",A[i],i<len ? " " : "\n")
   }

Improved version:

{ A[$1] = $2 }
END {
    for (i=1; i<=NR; i++)
printf("%s%s",A[i],i<NR ? " " : "\n")
    }

Note that the value of NR in END is sort of a gray area, but it works as
expected in GAWK, which is really all we care about.

--
[Donald] Trump didn't have it all handed to him by his parents,
like Hillary Clinton did.

- Some dumb cluck in Ohio; featured in Michael Moore's "Trumpland" -

Date Sujet#  Auteur
23 Dec 24 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal