]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(sort invocation): Add --random-sort (-R) and --seed.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 10 Dec 2005 08:10:20 +0000 (08:10 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 10 Dec 2005 08:10:20 +0000 (08:10 +0000)
doc/coreutils.texi

index 41f56d5b4bb998cfe0363736570cb502df523165..a7f59c51348cba09aaf536a90ec10412c3fb092e 100644 (file)
@@ -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