help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] How to set IFS temporarily? (along with assignment and a


From: Greg Wooledge
Subject: Re: [Help-bash] How to set IFS temporarily? (along with assignment and array initiation)
Date: Mon, 16 Mar 2015 12:57:43 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Mar 16, 2015 at 11:49:46AM -0500, Peng Yu wrote:
> I'm trying to understand readarray. It can only separate elements by
> newline. What about separating the elements by $'\0'? Is there an
> option for this case (I don't find it in the man page)?

Unfortunately, no.  That's one of my top wishlist features.  If you
want to read elements delimited by anything other than \n you have to
use a loop.

files=()
while IFS= read -r -d '' file; do
  files+=("$file")
done < <(find . -type f -print0)

read -d '' is another undocumented feature.  It means use \0 as the
delimiter.



reply via email to

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