bug-bash
[Top][All Lists]
Advanced

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

Re: a problem of mapfile


From: Ma Shimiao
Subject: Re: a problem of mapfile
Date: Fri, 11 Jan 2013 23:24:09 +0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0

Thank Greg for your answer very much.
This problem has confused me for 2 days. That seems I didn't read the manpage carefully.

On 01/11/2013 10:54 PM, Greg Wooledge wrote:
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]