From e076a7785103d56f72202b89cd4a60aaad86d59e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 10 Dec 2005 08:10:20 +0000 Subject: (sort invocation): Add --random-sort (-R) and --seed. --- doc/coreutils.texi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'doc') diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 41f56d5b4..a7f59c513 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -3396,6 +3396,15 @@ To compare such strings numerically, use the Reverse the result of comparison, so that lines with greater key values appear earlier in the output instead of later. +@item -R +@itemx --random-sort +@opindex -R +@opindex --random-sort +@cindex random sort + +Sort by random hash, i.e. perform a shuffle. This is done by hashing +the input keys and sorting based on the results. + @end table Other options are: @@ -3529,6 +3538,11 @@ This option can be useful in conjunction with @samp{perl -0} or reliably handle arbitrary file names (even those containing blanks or other special characters). +@itemx --seed @var{tempdir} +@opindex --seed +@cindex specify seed for random hash +Specify a seed for the @option{--random-sort} option. + @end table Historical (BSD and System V) implementations of @command{sort} have @@ -3695,6 +3709,16 @@ by the sort operation. @c printf 'c\n\nb\n\na\n'|perl -0pe 's/\n\n/\n\0/g'|sort -z|perl -0pe 's/\0/\n/g' @c @end example +@item +Shuffle a list of directories, but preserve the order of files within +each directory. For instance, one could use this to generate a music +playlist in which albums are shuffled but the songs of each album are +played in order. + +@example +find . -maxdepth 2 -type f | sort -t / -k2,2R -k3,3 +@end example + @end itemize -- cgit v1.2.3-70-g09d2