bug#9455: RFE: split --balanced (original) (raw)

[Top][All Lists]


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


From: Dave Yost
Subject: bug#9455: RFE: split --balanced
Date: Wed, 7 Sep 2011 05:31:26 -0700

Much better design. Thanks.

/ from my iPhone 4 /

On Sep 7, 2011, at 12:59 AM, Pádraig Brady <address@hidden> wrote:

On 09/07/2011 01:55 AM, Dave Yost wrote: > Z% for x in 1 2 3 4 5 6 7 _> for> do echo $x ; done | split --lines=3 _ > pipe> && for x in x?? ; do echo "=== x";catx" ; cat x";catx ; done > === xaa > 1 > 2 > 3 > === xab > 4 > 5 > 6 > === xac > 7 > > In some applications, you would like split to more evenly apportion the > output to the files, like this: > > Z% for x in 1 2 3 4 5 6 7 _> for> do echo $x ; done | split --balanced --lines=3 _ > pipe> && for x in x?? ; do echo "=== x";catx" ; cat x";catx ; done > === xaa > 1 > 2 > 3 > === xab > 4 > 5 > === xac > 6 > 7 >

So you'd like to distribute evenly across the last 2 buckets. It seems like it would be more general to specify the number of buckets instead and let split balance across them all, which is supported recently.

$ seq 7 | split -nr/3; tail x?? ==> xaa <== 1 4 7

==> xab <== 2 5

==> xac <== 3 6

$ seq 7 > 7; split -nl/3 7; tail x?? ==> xaa <== 1 2

==> xab <== 3 4

==> xac <== 5 6 7

Would that suffice?

cheers, Pádraig.