aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cli/rev.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/rev.md')
-rw-r--r--src/cli/rev.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cli/rev.md b/src/cli/rev.md
new file mode 100644
index 0000000..c00d517
--- /dev/null
+++ b/src/cli/rev.md
@@ -0,0 +1,18 @@
+# rev(1)
+
+```sh
+# Reverse each line of file(s), character by character.
+rev FILE [FILE]
+
+echo -e '123\nabc' | rev
+# 321
+# cba
+```
+
+## Example: remove the last 2 tokens with unknown length
+```sh
+# If the number of tokens in a line is unkown but we want to remove the last 2
+# tokens we can use rev(1).
+echo 'aa bb cc dd' | rev | cut -d ' ' -f3- | rev
+# aa bb
+```