From 21a13652df728c9571f899caf4949d5d46f49db7 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 1 May 2024 17:39:45 +0000 Subject: deploy: 7ca41565c4e70b212cb88a4d18c18fa35768df6d --- cli/sort.html | 261 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 cli/sort.html (limited to 'cli/sort.html') diff --git a/cli/sort.html b/cli/sort.html new file mode 100644 index 0000000..0d68a92 --- /dev/null +++ b/cli/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