bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to substitute in a string for the first n matches?


From: david kerns
Subject: Re: How to substitute in a string for the first n matches?
Date: Fri, 26 Mar 2021 16:16:43 -0700

don't hate me!

awk -v n=4 'BEGIN{x="rrrrrrrrrr";for(i=0;i<n;i++){sub("r","x",x)}print x}'

On Fri, Mar 26, 2021 at 1:57 PM Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> man gawk says.
>
> """
> gensub(r, s, h [, t])
>
> h is a number indicating which match of r to replace.
> """
>
> Is there a way to perform string substitution for the first n matches in
> awk?
>
> --
> Regards,
> Peng
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]