From c4fdf1c5f2c9ebedd0dedba4449c015f98aecda5 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 17 Jan 2024 23:37:49 +0000 Subject: deploy: 7199cf6515f9545f345b37a402293fc13bbb5a47 --- tools/sort.html | 261 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 tools/sort.html (limited to 'tools/sort.html') diff --git a/tools/sort.html b/tools/sort.html new file mode 100644 index 0000000..fbca67d --- /dev/null +++ b/tools/sort.html @@ -0,0 +1,261 @@ + + + + + + sort - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+

sort(1)

+
sort [opts] [file]
+  opts:
+    -r      reverse output
+    -b      ignore leading blanks
+
+    -n      sort by numeric
+    -h      sort by human numeric
+    -V      sort by version
+
+    -k<N>  sort by Nth key
+    -t<S>  field separator
+
+

Examples

+
# Sort by directory sizes.
+du -sh * | sort -h
+
+
# Sort numeric by second key.
+# The default key separator is non-blank to blank transition.
+echo 'a 4
+d 10
+c 21' | sort -k2 -n
+
+# Sort numeric by second key, split at comma.
+echo 'a,4
+d,10
+c,21' | sort -k2 -n -t,
+
+
+

Use --debug to annotate part of the line used to sort and hence debug the key usage.

+
+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + -- cgit v1.2.3