From 1a9fe17424c845e30544f35e6cc6a0ab8af22b64 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 23 Apr 2019 16:32:17 +0100 Subject: Add dehyphenate script --- dehyphenate.sh | 8 ++++++++ nonewlines.sh | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 dehyphenate.sh 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 -- cgit v1.2.1-24-ge1ad