summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-04-23 16:32:17 +0100
committerNick White <git@njw.name>2019-04-23 16:32:17 +0100
commit1a9fe17424c845e30544f35e6cc6a0ab8af22b64 (patch)
tree613265e73c3eaac14b7e17a51107139cc0e93e89
parent0c7c75a75433dd9b8b4fb833ad7039e1408519aa (diff)
Add dehyphenate script
-rw-r--r--dehyphenate.sh8
-rw-r--r--nonewlines.sh2
2 files changed, 9 insertions, 1 deletions
diff --git a/dehyphenate.sh b/dehyphenate.sh
new file mode 100644
index 0000000..5dae71b
--- /dev/null
+++ b/dehyphenate.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+usage="Usage: $0 dir
+
+Removes word-breaking hyphens from all .txt files in a directory."
+
+test $# -ne 1 && echo "$usage" && exit 1
+
+find "$1" -type f -name '*txt' -exec perl -0777pi -e 's/-\n(\S+)\s*/\1\n/smg' '{}' ';'
diff --git a/nonewlines.sh b/nonewlines.sh
index 3b5af27..e765d64 100644
--- a/nonewlines.sh
+++ b/nonewlines.sh
@@ -2,7 +2,7 @@
usage="Usage: $0 dir
Concatenates all .txt files in a directory together and removes all
-line breaks, saving the result to dirname.txt
+line breaks, saving the result to dirname.txt"
test $# -ne 1 && echo "$usage" && exit 1