help-bash
[Top][All Lists]
Advanced

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

Re: mapfile -C issue


From: alex xmb ratchev
Subject: Re: mapfile -C issue
Date: Sun, 18 Jun 2023 16:14:16 +0200

On Sun, Jun 18, 2023, 04:14 Greg Wooledge <greg@wooledge.org> wrote:

> On Sun, Jun 18, 2023 at 02:52:48AM +0200, alex xmb ratchev wrote:
> > i expected
> > 1 11
> > 2 22
> > 3 33
> > 1 44
> > 2 55
> > 3 66
> >
> > or the same with 0 as beginning instead of 1
>
> Then you want the callback function to be called every time, instead
> of every 3rd time.
>
> unicorn:~$ C() { printf '%d %d\n' "$(($1%3))" "$2"; }
> unicorn:~$ mapfile -t -C C -c 1 foo < <(printf %s\\n 11 22 33 44 55 66)
> 0 11
> 1 22
> 2 33
> 0 44
> 1 55
> 2 66
>
> You could use $(($1%3 + 1)) to get 1 2 3 1 2 3.  In any case, it's the %3
> in the callback function, and the use of -c 1, that are important here.
>

i see , i will do so
perfect code , excepts maybe speed
thanks great premade code .. :))

thx .. greets

>


reply via email to

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