Skip to main content

add an alias for reversing the order of lines of text

ID
a1a376b
date
2023-06-06 21:24:36+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
1a033bf
message
add an alias for reversing the order of lines of text
changed files
2 files, 33 additions

Changed files

text/README.md (906) → text/README.md (1468)

diff --git a/text/README.md b/text/README.md
index 2a7670a..7a82b53 100644
--- a/text/README.md
+++ b/text/README.md
@@ -25,6 +25,15 @@ These are utilities for manipulating streams of text; I consider them in a simil
   </dd>
 
   <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/text/reverse">
+      <code>reverse < [PATH]</code>
+    </a>
+  </dt>
+  <dd>
+    prints the lines of text, but in reverse order.
+  </dd>
+
+  <dt>
     <a href="https://github.com/alexwlchan/scripts/blob/main/text/randline">
       <code>tally < [PATH]</code>
     </a>
@@ -32,4 +41,14 @@ These are utilities for manipulating streams of text; I consider them in a simil
   <dd>
     prints a tally of the given text.
   </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/text/utf8info">
+      <code>echo [STRING] | utf8info</code>
+    </a>
+  </dt>
+  <dd>
+    read UTF-8 on stdin and print out the raw Unicode codepoints.
+    This is a Docker wrapper around a <a href="https://github.com/lunasorcery/utf8info">tool of the same name</a> by @lunasorcery.
+  </dd>
 </dl>

text/reverse (0) → text/reverse (272)

diff --git a/text/reverse b/text/reverse
new file mode 100755
index 0000000..0548d1d
--- /dev/null
+++ b/text/reverse
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# Reverses the lines of the input. e.g.
+#
+#     $ printf " apple \n banana \n coconut \n" | reverse
+#      coconut
+#      banana
+#      apple
+#
+# See https://stackoverflow.com/q/742466/1558022
+
+set -o errexit
+set -o nounset
+
+perl -e 'print reverse <>'