aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SUMMARY.md1
-rw-r--r--src/tools/README.md1
-rw-r--r--src/tools/sort.md35
3 files changed, 37 insertions, 0 deletions
diff --git a/src/SUMMARY.md b/src/SUMMARY.md
index 7a2155e..d802912 100644
--- a/src/SUMMARY.md
+++ b/src/SUMMARY.md
@@ -19,6 +19,7 @@
- [dot](./tools/dot.md)
- [ffmpeg](./tools/ffmpeg.md)
- [column](./tools/column.md)
+ - [sort](./tools/sort.md)
- [Resource analysis & monitor](./monitor/README.md)
- [lsof](./monitor/lsof.md)
diff --git a/src/tools/README.md b/src/tools/README.md
index 0b1666c..2aa2f5c 100644
--- a/src/tools/README.md
+++ b/src/tools/README.md
@@ -16,3 +16,4 @@
- [dot](./dot.md)
- [ffmpeg](./ffmpeg.md)
- [column](./column.md)
+- [sort](./sort.md)
diff --git a/src/tools/sort.md b/src/tools/sort.md
new file mode 100644
index 0000000..e74b490
--- /dev/null
+++ b/src/tools/sort.md
@@ -0,0 +1,35 @@
+# 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
+```sh
+# Sort by directory sizes.
+du -sh * | sort -h
+```
+
+```sh
+# 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.