about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-12-17 00:52:04 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-12-17 00:52:04 +0100
commit0ff2299c083319d94056ae78c4ba8a973098d3c9 (patch)
tree8b61ec91f412f8e307b6e031fde31b843d038e3f
parent5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e (diff)
downloadrnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.tar.gz
rnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.tar.xz
rnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.zip
add shell script variant of pipe mode HEAD master
-rwxr-xr-xrnl.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/rnl.sh b/rnl.sh
new file mode 100755
index 0000000..d9d70cd
--- /dev/null
+++ b/rnl.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# rnl - remove final newlines
+
+tr1='\012 '
+tr2=' \012'
+pat='$s/ *$/ /'
+
+while getopts 0aso opt; do
+	case "$opt" in
+		0) tr1='\0 '; tr2=' \0';;
+		a) pat='$s/ *$//';;
+		s) pat='$s/ *$/ /';;
+		o) pat='$s/ $//';;
+		'?') exit 1;;
+	esac
+done
+
+tr "$tr1" "$tr2" | sed "$pat" | tr "$tr2" "$tr1"