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

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.