aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown1
-rwxr-xr-xbin/stex15
-rw-r--r--man/man1/stex.115
3 files changed, 31 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 8b2f23a0..c4f3c8a9 100644
--- a/README.markdown
+++ b/README.markdown
@@ -357,6 +357,7 @@ 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.
+* `stex(1)` strips extensions from filenames
* `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,
diff --git a/bin/stex b/bin/stex
new file mode 100755
index 00000000..f4173a88
--- /dev/null
+++ b/bin/stex
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Strip an extension from the given files
+if [ "$#" -lt 2 ] ; then
+ printf >&2 'Need an extension .ext and a filename\n'
+ exit 2
+fi
+ex=0 ext=$1
+shift
+for sn ; do
+ sn=${sn%/}
+ dn=${sn%"$ext"}
+ [ "$sn" != "$dn" ] || continue
+ mv -- "$sn" "$dn" || ex=1
+done
+exit "$ex"
diff --git a/man/man1/stex.1 b/man/man1/stex.1
new file mode 100644
index 00000000..26392fb9
--- /dev/null
+++ b/man/man1/stex.1
@@ -0,0 +1,15 @@
+.TH STEX 1 "August 2016" "Manual page for stex"
+.SH NAME
+.B stex
+\- strip extensions from the given filenames if present
+.SH SYNOPSIS
+.B stex .ext a.ext b.ext c d.foo
+.br
+.B stex .bar *
+.SH DESCRIPTION
+.B stex
+renames any of the files given as its trailing arguments to remove the
+extension given as its first argument. It is not an error if none of the files
+have the extension.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>