Sujet : Re: "sed" question
De : jshem (at) *nospam* yaxenu.org (Julieta Shem)
Groupes : comp.lang.awkDate : 09. Mar 2024, 15:52:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <877cibsbja.fsf@yaxenu.org>
References : 1 2 3 4
Christian Weisgerber <
naddy@mips.inka.de> writes:
On 2024-03-06, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
$ awk '{print $1, "1-1"}' newsrc-news.eternal-september.org-test >
newsrc-news.eternal-september.org
>
In this specific case of regular data you can simplify that to
>
awk '$2="1-1"' sourcefile > targetfile
>
That had me scratching my head. You can't have an action without
enclosing braces. But it's still legal syntax because... it's an
expression serving as a pattern. The assignment itself is a side
effect.
Without braces, the default action takes place, which is ``{print}''.