From 86b3532b4584355b85998fddf1db0d995109ff12 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 3 Aug 2016 21:21:52 +1200 Subject: Add stws(1) --- README.markdown | 2 ++ bin/stws | 11 +++++++++++ man/man1/stws.1 | 11 +++++++++++ 3 files changed, 24 insertions(+) create mode 100755 bin/stws create mode 100644 man/man1/stws.1 diff --git a/README.markdown b/README.markdown index 95153945..e8efad5f 100644 --- a/README.markdown +++ b/README.markdown @@ -353,6 +353,8 @@ Installed by the `install-bin` target: * `shb(1)` attempts to build shebang lines for scripts from `$PATH`. * `spr(1)` posts its input to the sprunge.us pastebin. * `stbl(1)` strips a trailing blank line from the files in its arguments. +* `stws(1)` strips trailing spaces from the ends of lines of the files in its + arguments. * `sue(8)` execs `sudoedit(8)` as the owner of all the file arguments given, perhaps in cases where you may not necessarily have `root` `sudo(8)` privileges. diff --git a/bin/stws b/bin/stws new file mode 100755 index 00000000..1514a979 --- /dev/null +++ b/bin/stws @@ -0,0 +1,11 @@ +#!/bin/sh +# Strip trailing spaces on one or more files +if [ "$#" -eq 0 ] ; then + printf >&2 'tstf: Need filenames\n' +fi +for fn ; do + ed -s -- "$fn" <<'EOF' +g/ *$/ s/ *$// +w +EOF +done diff --git a/man/man1/stws.1 b/man/man1/stws.1 new file mode 100644 index 00000000..730d42aa --- /dev/null +++ b/man/man1/stws.1 @@ -0,0 +1,11 @@ +.TH STWS 1 "August 2016" "Manual page for stws" +.SH NAME +.B stws +\- strip trailing spaces from files +.SH USAGE +.B stws FILE1 [FILE2 ...] +.SH DESCRIPTION +Applies ed(1) to remove all trailing spaces at the end of lines, if present, +from each of the given files. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3