help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Array Expansion


From: Andy Chu
Subject: Re: [Help-bash] Array Expansion
Date: Sun, 25 Jun 2017 15:59:03 -0700

On Sun, Jun 25, 2017 at 1:17 PM, João Eiras <address@hidden> wrote:

> This is most likely what you want:
>
> IFS=$'\x0a'
> listoffiles=( $(find ...) )
>

This seems like an obscure way to write $'\n'  :)   (my second suggestion)


> > find -print0 | (i=0; while read -d '' line; do echo $line; ((i++)); done;
> > echo $i )
> >
>
> You're reading the values into a sub-shell, which are not inherited by
> the main shell.
>

That's true, but I think you might not have gotten the point of the
snippet.  The point is that you can use $i after the while loop, but
without the subshell you can't.  The subshell is part of the pipeline.

That might not be convenient for all scripts, but it's sufficient for many
(especially in the absense of lastpipe).

Andy


reply via email to

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