Re: new coreutil? shuffle - randomize file contents
From:
Philip Rowlands
Subject:
Re: new coreutil? shuffle - randomize file contents
Date:
Thu, 2 Jun 2005 11:30:40 +0100 (BST)
On Thu, 2 Jun 2005, James Youngman wrote:
>I think the consensus is that the functionality belongs in "sort".
>Beyond that things are a bit less clear. However, Paul put forward a
>proposed usage which adapts the current -k option (see
>http://lists.gnu.org/archive/html/bug-coreutils/2005-05/msg00179.html).
>Nobody made any comments suggesting that that wasn't a good way of
>doing things.
>
>> or that it would be good to have both, or is it still in question
>> whether either would be accepted?
>
>Both is probably uncalled for though I personally would put something
>like this in /usr/local/bin/shuffle:
>
>#! /bin/sh
>exec sort -k R -- "$@"
FWIW, I favour this solution for both sort and shuffle. Determining
behaviour via argv[0] (a la grep/egrep/fgrep) would also work.
Paul's statement:
> It's not as easy to implement as it sounds, I'm afraid; even if you
> can assume /dev/random or /dev/urandom.
is a slight concern, but I imagine the problems are applicable to *any*
shuffling utility. Is it that the app must guarantee all lines of a
non-seekable stdin must have an equal chance of any sort order?
Cheers,
Phil