Deutsch   English   Français   Italiano  
<v1t9hi$u4lh$1@news.xmission.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: alt.comp.lang.awk,comp.lang.awk
Subject: Re: printing words without newlines?
Date: Mon, 13 May 2024 14:53:38 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <v1t9hi$u4lh$1@news.xmission.com>
References: <v1pi7c$2b87j$1@dont-email.me> <v1sdji$tofu$2@news.xmission.com>
Injection-Date: Mon, 13 May 2024 14:53:38 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
	logging-data="987825"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
Bytes: 1529
Lines: 27

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" -