summaryrefslogtreecommitdiff
path: root/doc/coreutils.texi
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2009-07-25 00:46:12 +0100
committerPádraig Brady <P@draigBrady.com>2009-07-27 01:34:35 +0100
commit2f4188ebec8a5cd833dc8061b714145a58dc86aa (patch)
tree7ce2c6b1a7584a6dd632ceef5e81f3128f73f815 /doc/coreutils.texi
parent0bf77fc8ec08b766f44fba9f5958b06c1ef9ad74 (diff)
downloadcoreutils-2f4188ebec8a5cd833dc8061b714145a58dc86aa.tar.xz
doc: add a sort by line length example
* doc/coreutils.texi (sort invocation): Add an example showing how to sort data not directly supported by the sort command.
Diffstat (limited to 'doc/coreutils.texi')
-rw-r--r--doc/coreutils.texi11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 334d932de..a804adb5b 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -4258,6 +4258,17 @@ by the sort operation.
@c @end example
@item
+Use the common @acronym{DSU, Decorate Sort Undecorate} idiom to
+sort lines according to their length.
+
+@example
+awk '@{print length, $0@}' /etc/passwd | sort -n | cut -f2- -d' '
+@end example
+
+In general this technique can be used to sort data that the @command{sort}
+command does not support, or is inefficient at, sorting directly.
+
+@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