From 5e97e30ffe0f4a625a58d0ad547ea77ee366f0bf Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 5 May 2022 15:12:38 +0200 Subject: [PATCH] Added sort and uniq notes to the knowledge base --- knowledge base/sort.md | 17 +++++++++++++++++ knowledge base/uniq.md | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 knowledge base/sort.md create mode 100644 knowledge base/uniq.md diff --git a/knowledge base/sort.md b/knowledge base/sort.md new file mode 100644 index 0000000..161396e --- /dev/null +++ b/knowledge base/sort.md @@ -0,0 +1,17 @@ +# Sort + +## TL;DR + +```shell +# Sort all given lines. +sort path/to/file + +# Sort all lines reverse. +sort -r path/to/file + +# Sort lines numerically. +sort -n path/to/file + +# Sort lines and remove duplicates. +sort -u path/to/file +``` diff --git a/knowledge base/uniq.md b/knowledge base/uniq.md new file mode 100644 index 0000000..1f690a6 --- /dev/null +++ b/knowledge base/uniq.md @@ -0,0 +1,20 @@ +# Uniq + +## TL;DR + +```shell +# Print all but duplicates lines. +uniq path/to/file + +# Only print unique lines. +uniq -u path/to/file + +# Only print repeating lines. +uniq -d path/to/file + +# Count unique lines only. +uniq -cu path/to/file + +# Count duplicated lines only. +uniq -cd path/to/file +```