Re: printing words without newlines?

Liste des GroupesRevenir à cl awk 
Sujet : Re: printing words without newlines?
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : alt.comp.lang.awk comp.lang.awk
Date : 12. May 2024, 13:11:27
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <v1qblf$solc$1@news.xmission.com>
References : 1 2
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <e0be0c38-e14e-45ba-ac87-5e2e4bd4f5cd@scorecrow.com>,
Bruce Horrocks  <07.013@scorecrow.com> wrote:
...
You need to set ORS in the BEGIN { } section (or on the command line).

This is demonstrably false.  You can set ORS whenever/wherever you want.
Whatever value it has when a plain "print" statement is executed, is what
will be used.  You are probably about thinking about the various variables
that affect input parsing. These variables clearly must be set prior to the
reading of the input, which usually means they need to be set in BEGIN (or
via something like -F or -v on the command line).

One of my favorite idioms (and one that might actually be useful to OP) is:

# Print every 3 input lines as a single output line
# Yes, this single line is the whole program!
ORS = NR % 3 ? " " : "\n"

See
<https://www.gnu.org/software/gawk/manual/html_node/Output-Separators.html>
for an example - just replace the "\n\n" in the example with " " to see
the effect you are looking for.

Of course, the whole point of this thread is that none of us has any idea
what OP is talking about or what his actual problem is.  We can only guess...

--
"It does a lot of things half well and it's just a garbage heap of ideas that are
mutually exclusive."

- Ken Thompson, on C++ -

Date Sujet#  Auteur
12 May 24 * printing words without newlines?19David Chmelik
12 May 24 +* Re: printing words without newlines?5Bruce Horrocks
12 May 24 i+- Re: printing words without newlines?1Bruce Horrocks
12 May 24 i`* Re: printing words without newlines?3Kenny McCormack
13 May 24 i +- Re: printing words without newlines?1David Chmelik
13 May 24 i `- Re: printing words without newlines?1Kaz Kylheku
13 May 24 +* Re: printing words without newlines?3Kenny McCormack
13 May 24 i`* Re: printing words without newlines?2Kenny McCormack
15 Jul 24 i `- Resurrecting an old thread (Was: printing words without newlines?)1Kenny McCormack
13 May 24 +- Re: printing words without newlines?1Janis Papanagnou
13 May 24 +* Re: printing words without newlines?4Kaz Kylheku
13 May 24 i`* Re: printing words without newlines?3Kenny McCormack
14 May 24 i `* Re: printing words without newlines?2Kaz Kylheku
14 May 24 i  `- Array indices are small integers? (Was: printing words without newlines?)1Kenny McCormack
16 May 24 `* Re: printing words without newlines?5Ed Morton
16 May 24  `* Re: printing words without newlines?4Janis Papanagnou
16 May 24   +* Once upon a time... (Was: printing words without newlines?)2Kenny McCormack
16 May 24   i`- Re: Once upon a time... (Was: printing words without newlines?)1Kenny McCormack
17 May 24   `- Re: printing words without newlines?1Ed Morton

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal