[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mapfile -C issue
From: |
Greg Wooledge |
Subject: |
Re: mapfile -C issue |
Date: |
Sat, 17 Jun 2023 22:13:57 -0400 |
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.
- mapfile -C issue, alex xmb ratchev, 2023/06/17
- Re: mapfile -C issue, alex xmb ratchev, 2023/06/17
- Re: mapfile -C issue, Emanuele Torre, 2023/06/17
- Re: mapfile -C issue, alex xmb ratchev, 2023/06/18
- Re: mapfile -C issue, Chet Ramey, 2023/06/19
- Re: mapfile -C issue, alex xmb ratchev, 2023/06/19
- Re: mapfile -C issue, Emanuele Torre, 2023/06/19
- Re: mapfile -C issue, alex xmb ratchev, 2023/06/19
Re: mapfile -C issue,
Greg Wooledge <=