i installed bash dev , but there is no `help cut` On Wed, Jun 4, 2025, 3:43 PM Chet Ramey <chet.ra...@case.edu> wrote:
> On 6/2/25 5:58 AM, Duncan Roe wrote: > > Hi, > > > > `cut -a ARRAY ...` puts its last line of output in ARRAY[0] and discards > any > > other elements ARRAY used to have. I tried 3 alternatives: > > Thanks for the report. Yes, sometimes marrying the multiple-line-oriented > output of a tool like `cut' to one-dimensional arrays is awkward. > > This has to support output that consists of one field (bytes/chars) or > multiple fields (well, fields). When you use -f to cut fields, each > selected field is put into a separate element of the array. When you > select bytes or characters, the selected bytes get put into array[0] as > a single field. There's no current way to assign multiple array elements > when you don't supply -f. > > The usual behavior of builtins that take array variable names as arguments > is to unset the array before assigning anything, so I don't see any reason > to change that. If you want to append to an existing array, there are ways > to do that with array `cut' populates. > > I think the bigger issue is your alternative B: how to handle multiple > lines of output with a single one-dimensional array. > > > Alternative B: empty out the array then put lines of output in > successive array > > elements. > > Is it useful to combine multiple selected fields (-f) into one space- > separated field so `cut' can put the selected portions of each line into > a corresponding array element? > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/ > >