[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: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Is there a way to allow `read` get empty field with IFS=$'\t'? |
Date: |
Wed, 7 Mar 2018 16:58:52 -0500 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Wed, Mar 07, 2018 at 03:52:49PM -0600, Peng Yu wrote:
> Hi,
>
> 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.
>
> IFS=$'\t' read -r -a a <<< $'a\t\tb c\td'
> declare -p a
> declare -a a=([0]="a" [1]="b c" [2]="d")
Convert your tab separators into something that is not IFS whitespace.
Then use that (whatever you chose) as IFS.
Or don't use bash.