[Top][All Lists]

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

Re: a problem of mapfile

From: Greg Wooledge
Subject: Re: a problem of mapfile
Date: Fri, 11 Jan 2013 09:54:14 -0500
User-agent: Mutt/

On Fri, Jan 11, 2013 at 10:21:55PM +0800, Ma Shimiao wrote:
> I used commands as follows:
> $seq 5 | mapfile -C echo -c1
> 0 1
> 1 2
> 2 3
> 3 4
> 4 5
> I would have expectd 1,2,3,4,5 above from the"help mapfile".
> Is it a bug of  mapfile?

The help says:

    When CALLBACK is evaluated, it is supplied the index of the next array
    element to be assigned and the line to be assigned to that element
    as additional arguments.

So your full callback command, executed on each item read, is:

  echo 'index number' 'line of input including newline'

echo adds an additional newline of its own.  The first array index number
is 0, which corresponds to the line containing $'1\n'.

reply via email to

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