[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Is there a way to allow `read` get empty field with IFS=
From: |
Peng Yu |
Subject: |
Re: [Help-bash] Is there a way to allow `read` get empty field with IFS=$'\t'? |
Date: |
Fri, 9 Mar 2018 21:23:57 -0600 |
On Thu, Mar 8, 2018 at 11:47 PM, Grisha Levit <address@hidden> wrote:
> On Wed, Mar 7, 2018 at 4:53 PM Peng Yu <address@hidden> wrote:
>>
>> When IFS=$'\t', `read` will not get empty fields like the one between
>> 'a' and 'b c' below. Is there a way to allow it do so? Thanks.
>
>
> You can use mapfile with -d like
>
> $ mapfile -t -d $'\t' a < <(printf 'a\t\tb c\td')
> $ declare -p a
> declare -a a=([0]="a" [1]="" [2]="b c" [3]="d")
--
Regards,
Peng