GNU bug report logs - #9455
RFE: split --balanced

Previous Next

Package: coreutils;

Reported by: Dave Yost <Dave <at> Yost.com>

Date: Wed, 7 Sep 2011 01:02:01 UTC

Severity: wishlist

Fixed in version 8.8

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 9455 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Dave Yost <Dave <at> Yost.com>
Cc: 9455 <at> debbugs.gnu.org
Subject: Re: bug#9455: RFE: split --balanced
Date: Wed, 07 Sep 2011 08:59:16 +0100
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" ; cat $x ; 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" ; cat $x ; 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.




This bug report was last modified 13 years and 339 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.