diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-12-17 00:52:04 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-12-17 00:52:04 +0100 |
commit | 0ff2299c083319d94056ae78c4ba8a973098d3c9 (patch) | |
tree | 8b61ec91f412f8e307b6e031fde31b843d038e3f | |
parent | 5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e (diff) | |
download | rnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.tar.gz rnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.tar.xz rnl-0ff2299c083319d94056ae78c4ba8a973098d3c9.zip |
-rwxr-xr-x | rnl.sh | 18 |
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" |