1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-08 17:51:13 +02:00

(sort invocation): Add --random-sort (-R) and --seed.

This commit is contained in:
Paul Eggert
2005-12-10 08:10:20 +00:00
parent 569c4876bc
commit e076a77851
+24
View 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