summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-04-23 17:41:06 +0100
committerNick White <git@njw.name>2019-04-23 17:41:06 +0100
commit17f3e2287977895a0c127384472678be78cec022 (patch)
treec647a51a76973440d0b4330587a29d94be56b880
parent1a9fe17424c845e30544f35e6cc6a0ab8af22b64 (diff)
Save dehyphenated text to a different file, rather than overwriting the original
-rw-r--r--dehyphenate.sh6
-rw-r--r--nonewlines.sh2
2 files changed, 6 insertions, 2 deletions
diff --git a/dehyphenate.sh b/dehyphenate.sh
index 5dae71b..7656476 100644
--- a/dehyphenate.sh
+++ b/dehyphenate.sh
@@ -5,4 +5,8 @@ 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' '{}' ';'
+find "$1" -type f -name '*.txt' | while read i; do
+ d=`dirname "$i"`
+ b=`basename "$i" .txt`
+ perl -0777p -e 's/-\n(\S+)\s*/\1\n/smg' "$i" > "$d/$b.dehyphenated.txt"
+done
diff --git a/nonewlines.sh b/nonewlines.sh
index e765d64..499b791 100644
--- a/nonewlines.sh
+++ b/nonewlines.sh
@@ -7,6 +7,6 @@ line breaks, saving the result to dirname.txt"
test $# -ne 1 && echo "$usage" && exit 1
d=`dirname "$1"`
-cat "$1"/*txt | tr -d '\n' > "${d}.txt"
+cat "$1"/*.dehyphenated.txt | tr -d '\n' > "${d}.txt"
echo "Saved all text, with no newlines, to ${d}.txt"