bug-coreutils
[Top][All Lists]
Advanced

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

bug#15055: shuf: add --all-permutations option


From: Collin Funk
Subject: bug#15055: shuf: add --all-permutations option
Date: Sat, 22 Aug 2026 12:58:59 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Dan Jacobson said:

> (info "(coreutils) shuf invocation") says
>
>    These examples all have four input lines, so `shuf' might produce any
>    of the twenty-four possible permutations of the input.  In general, if
>    there are N input lines, there are N! (i.e., N factorial, or N * (N -
>    1) * ... * 1) possible output permutations.
>
> Please add an option to produce all permutations.
>
> Perhaps separated by blank lines or a --separator=...

I don't think it would be a good idea to implement this, since it would
only be usable for inputs with very few lines. Printing N factorial
different permutations gets unreasonable very quickly. A common example
is 52! for the number of unique ways that you can shuffle a deck of
cards:

    $ python3 -c 'import math; print(math.factorial(52))'
    80658175170943878571660636856403766975289505440883277824000000000000

And 52 lines is short relative to the number of lines that 'shuf' can
and is used to process.

Collin





reply via email to

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